summaryrefslogtreecommitdiff
path: root/module/tex/context/third/simpleslides/automata
diff options
context:
space:
mode:
Diffstat (limited to 'module/tex/context/third/simpleslides/automata')
-rw-r--r--module/tex/context/third/simpleslides/automata/automata-eca.lua14
-rw-r--r--module/tex/context/third/simpleslides/automata/automata-life.lua6
2 files changed, 6 insertions, 14 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
diff --git a/module/tex/context/third/simpleslides/automata/automata-life.lua b/module/tex/context/third/simpleslides/automata/automata-life.lua
index 01fc97b..5b171e2 100644
--- a/module/tex/context/third/simpleslides/automata/automata-life.lua
+++ b/module/tex/context/third/simpleslides/automata/automata-life.lua
@@ -90,8 +90,6 @@ function gol.parse_rule (raw_rule)
end
function gol.apply_rule (cell, cnt, rule, fade, keep)
- --local live, dead = "1", "0"
- --local new = dead
local new = 0
local live = "1"
local stay = rule.stay
@@ -154,8 +152,8 @@ gol.formats[".gol"] = function (fname)
local line = Cs(cell^1) / function (l)
if not len then len = string.len(l) end
if len ~= string.len(l) then
- -- inconsistent horizontal sizes; kill off program
- return nil
+ -- inconsistent horizontal sizes
+ return false
else
table.insert(tmp,l)
end