summaryrefslogtreecommitdiff
path: root/tex
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2012-02-12 22:28:38 +0100
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2012-02-12 22:28:38 +0100
commit2dd409c42aa4f1767cd32204ef2a17743da7f27e (patch)
tree54cf4619ba8ab3e0f4c794b172c4a86020d4dc0f /tex
parent47b7388988a326f223c552bb714a2bc1cc740db5 (diff)
downloadcyrillicnumbers-2dd409c42aa4f1767cd32204ef2a17743da7f27e.tar.gz
finished docs
Diffstat (limited to 'tex')
-rw-r--r--tex/context/third/cyrillicnumbers/cyrillicnumbers.lua51
-rw-r--r--tex/context/third/cyrillicnumbers/t-cyrillicnumbers.mkiv12
2 files changed, 55 insertions, 8 deletions
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/Кириллическая_система_счис
</typing>
--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