summaryrefslogtreecommitdiff
path: root/module/tex/context/third/simpleslides/automata/automata-eca.lua
diff options
context:
space:
mode:
Diffstat (limited to 'module/tex/context/third/simpleslides/automata/automata-eca.lua')
-rw-r--r--module/tex/context/third/simpleslides/automata/automata-eca.lua14
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