From 805134d2763b79ae1f8212092c5d76d934c88dd2 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 16 Aug 2010 16:03:49 +0200 Subject: revised some code; updated interface.xml --- .../context/third/simpleslides/automata/automata-eca.lua | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'module/tex/context/third/simpleslides/automata/automata-eca.lua') 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), -- 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 -- cgit v1.2.3