1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
-- word generator
-- not all output is good or even phonotactically valid
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','s','r','n','m','t','h','d','g','z','y','ts','sh','j','w','kk','tt','ss','b','p','pp'}, 1.15)
local V = R("auioe", 1.3)
local N = R({"","ń"}, 8)
local S = _{R({C,""}, 10),V,N}
local W = _({S,R({S,"",_{S,S},_{S,S,S}},3)})
local the = ... and tonumber(...) or 10
for i=0,the do
print(W())
end
|