From 2dd409c42aa4f1767cd32204ef2a17743da7f27e Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 12 Feb 2012 22:28:38 +0100 Subject: finished docs --- .../third/cyrillicnumbers/cyrillicnumbers.lua | 51 ++++++++++++++++++---- .../third/cyrillicnumbers/t-cyrillicnumbers.mkiv | 12 +++++ 2 files changed, 55 insertions(+), 8 deletions(-) (limited to 'tex/context') diff --git a/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua index cec98c7..2041ead 100644 --- a/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua +++ b/tex/context/third/cyrillicnumbers/cyrillicnumbers.lua @@ -32,15 +32,16 @@ http://ru.wikipedia.org/wiki/Кириллическая_система_счис --ldx]]-- -local iowrite = io.write -local mathceil = math.ceil -local mathfloor = math.floor -local tableconcat = table.concat +local iowrite = io.write +local mathceil = math.ceil +local mathfloor = math.floor +local stringformat = string.format +local tableconcat = table.concat --local tablemaxn = table.maxn -local tableinsert = table.insert -local utf8char = unicode.utf8.char -local utf8len = unicode.utf8.len -local utfupper = unicode.utf8.upper +local tableinsert = table.insert +local utf8char = unicode.utf8.char +local utf8len = unicode.utf8.len +local utfupper = unicode.utf8.upper local cyrnum = { placetitlo = "font", @@ -286,4 +287,38 @@ converters.Cyrillicnumerals = Tocyrillic function commands.cyrillicnumerals (n) context(tocyrillic(n)) end function commands.Cyrillicnumerals (n) context(Tocyrillic(n)) end +--- Fun --------------------------------------------------------- + +local f_peano = [[suc(%s)]] +local do_topeano = function (n) + n = tonumber(n) or 0 + if n == 0 then return "0" end + local result = stringformat(f_peano, 0) + if n == 1 then return result end + for i=2, n do + result = stringformat(f_peano, result) + end + return result +end + +local s_churchp = [[λf.λx.\;]] +local s_church0 = [[x]] +local s_church1 = [[f\,x]] +local f_church = [[f(%s)]] +local do_tochurch = function (n) + if n == 0 then return s_churchp .. s_church0 + elseif n == 1 then return s_churchp .. s_church1 end + local result = stringformat(f_church, s_church1) + for i=2, n do + result = stringformat(f_church, result) + end + return s_churchp .. result +end + +converters.topeano = do_topeano +converters.tochurch = do_tochurch + +commands.peanonumerals = function (n) context(do_topeano(n)) end +commands.churchnumerals = function (n) context.mathematics(do_tochurch(n)) end + -- vim:ft=lua:ts=2:sw=2:expandtab:fo=croql diff --git a/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv b/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv index e087a43..291f562 100644 --- a/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv +++ b/tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv @@ -454,6 +454,18 @@ \defineconversion[cyr] [\cyrillicnumerals] \defineconversion[Cyr] [\Cyrillicnumerals] +% \unprotect \endinput + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Fun %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\peano#1{\ctxcommand{peanonumerals(\number#1)}} +\defineconversion[peano][\peano] + +\def\church#1{\ctxcommand{churchnumerals(\number#1)}} +\defineconversion[church][\church] + \unprotect \endinput % vi:ft=context:fo=co:ts=2:expandtab:sw=2 -- cgit v1.2.3