Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
21
Task/Amb/Lua/amb-1.lua
Normal file
21
Task/Amb/Lua/amb-1.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
function amb (set)
|
||||
local workset = {}
|
||||
if (#set == 0) or (type(set) ~= 'table') then return end
|
||||
if #set == 1 then return set end
|
||||
if #set > 2 then
|
||||
local first = table.remove(set,1)
|
||||
set = amb(set)
|
||||
for i,v in next,first do
|
||||
for j,u in next,set do
|
||||
if v:byte(#v) == u[1]:byte(1) then table.insert(workset, {v,unpack(u)}) end
|
||||
end
|
||||
end
|
||||
return workset
|
||||
end
|
||||
for i,v in next,set[1] do
|
||||
for j,u in next,set[2] do
|
||||
if v:byte(#v) == u:byte(1) then table.insert(workset,{v,u}) end
|
||||
end
|
||||
end
|
||||
return workset
|
||||
end
|
||||
8
Task/Amb/Lua/amb-2.lua
Normal file
8
Task/Amb/Lua/amb-2.lua
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
result = amb({{'the','that','a'},{'frog','elephant','thing'},{'walked','treaded','grows'},{'slowly','quickly'}})
|
||||
for i,v in next,result do
|
||||
io.write (i,':\t')
|
||||
for j,u in next,v do
|
||||
io.write (u,' ')
|
||||
end
|
||||
io.write ('\n')
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue