diff options
author | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-08-16 16:03:49 +0200 |
---|---|---|
committer | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-08-16 16:03:49 +0200 |
commit | 805134d2763b79ae1f8212092c5d76d934c88dd2 (patch) | |
tree | 94971a5a91d9c84856cf86c420bf16c4bf9baa77 /module/tex/context/third/simpleslides/automata/automata-eca.lua | |
parent | 04fb784929a939f3a252cb307f3d762eda4b6882 (diff) | |
download | automata-backgrounds-805134d2763b79ae1f8212092c5d76d934c88dd2.tar.gz |
revised some code; updated interface.xml
Diffstat (limited to 'module/tex/context/third/simpleslides/automata/automata-eca.lua')
-rw-r--r-- | module/tex/context/third/simpleslides/automata/automata-eca.lua | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/module/tex/context/third/simpleslides/automata/automata-eca.lua b/module/tex/context/third/simpleslides/automata/automata-eca.lua index 27450ba..4dcf3c7 100644 --- a/module/tex/context/third/simpleslides/automata/automata-eca.lua +++ b/module/tex/context/third/simpleslides/automata/automata-eca.lua @@ -3,7 +3,7 @@ -- FILE: automata-eca.lua -- DESCRIPTION: drawing elementary cellular automata -- REQUIREMENTS: ConTeXt MkIV with Simple Slides module --- BUGS: uncountable +-- BUGS: uncountable minus the few I found -- AUTHOR: Philipp Gesang (Phg), <megas.kapaneus@gmail.com> -- VERSION: 1.0 -- CREATED: 14/08/10 19:43:35 CEST @@ -20,10 +20,8 @@ local help = gol.helpers local C, Cs, Ct, P, R, S, match = lpeg.C, lpeg.Cs, lpeg.Ct, lpeg.P, lpeg.R, lpeg.S, lpeg.match - eca = {} - function eca.parse_file (fname) local f = assert(io.open(fname, "r"), "No such file: "..fname..".") local init = f:read("*all") @@ -63,7 +61,7 @@ function eca.next_line(from, rule) --from = string.format("0%s0", from) -- too slow local cell = C(S"01") - local cells= Ct(cell * #(cell * cell)) / function (t) + local cells= Ct(cell * #(cell * cell)) / function (t) -- I ♡ LPEG local three = t[1]..t[2]..t[3] new = new .. rule[three] end @@ -99,12 +97,8 @@ end function eca.successive (current) local thisframe current.from, thisframe = eca.gen_frame(current.from, current.framesize, current.rule) - if not context then -- cli invocation - for _,j in ipairs(thisframe) do - io.write(j:gsub("0","·"):gsub("1","O").."\n") - end - else - + for _,j in ipairs(thisframe) do + io.write(j:gsub("0","·"):gsub("1","O").."\n") end return 0 end |