From dde0a3cddc8dec7bbfc619d76d49222c600b8d7e Mon Sep 17 00:00:00 2001 From: the lemons Date: Sat, 26 Mar 2022 06:32:47 -0500 Subject: apioform --- wordgen.lua | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 wordgen.lua (limited to 'wordgen.lua') diff --git a/wordgen.lua b/wordgen.lua new file mode 100644 index 0000000..4063c0c --- /dev/null +++ b/wordgen.lua @@ -0,0 +1,50 @@ +math.randomseed(os.time()) + +local function R(bee, dist) + dist = dist or 2 + return function() + local i = 1 + repeat + if math.random() * dist > 1 then + break + end + i = i + 1 + until i >= #bee + if type(bee) == 'string' then + return bee:sub(i,i) + else + local the = bee[i] + if type(the) == 'function' then + the = the() + end + return the + end + end +end + +local function _(the) + return function() + local a = {} + for i,v in ipairs(the) do + if type(v) == 'function' then + a[i] = v() + else + a[i] = v + end + end + return table.concat(a) + end +end + +local C = R({'k','t','r','n','s','m','h','d','g','z','kk','tt','ss','sh','j','y','b','l','p','pp'}, 1.15) +local V = R("auioe", 1.3) +local N = R({"","ń"}, 4) +local S = _{R({C,""}, 10),V,N} + +local W = _({S,R({S,"",_{S,S},_{S,S,S}},2.5)}) + +local the = ... and tonumber(...) or 10 + +for i=0,the do + print(W()) +end -- cgit v1.2.3