diff options
| author | the lemons <citrons@mondecitronne.com> | 2022-03-26 06:32:47 -0500 |
|---|---|---|
| committer | the lemons <citrons@mondecitronne.com> | 2022-03-26 06:32:47 -0500 |
| commit | dde0a3cddc8dec7bbfc619d76d49222c600b8d7e (patch) | |
| tree | ba4c62d420413849765b79c6e4ac037fd665a458 /wordgen.lua | |
apioform
Diffstat (limited to 'wordgen.lua')
| -rw-r--r-- | wordgen.lua | 50 |
1 files changed, 50 insertions, 0 deletions
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 |
