Amb: Difference between revisions
Content deleted Content added
added OpenEdge solution |
Add Seed7 example |
||
Line 1,791:
(list w-1 w-2 w-3 w-4))
</lang>
=={{Header|Seed7}}==
<lang seed7>$ include "seed7_05.s7i";
const type: setListType is array array string;
const func array string: amb (in string: word1, in setListType: listOfSets) is func
result
var array string: result is 0 times "";
local
var string: word2 is "";
begin
for word2 range listOfSets[1] do
if length(result) = 0 and word1[length(word1) len 1] = word2[1 len 1] then
if length(listOfSets) = 1 then
result := [] (word1) & [] (word2);
else
result := amb(word2, listOfSets[2 ..]);
if length(result) <> 0 then
result := [] (word1) & result;
end if;
end if;
end if;
end for;
end func;
const func array string: amb (in setListType: listOfSets) is func
result
var array string: result is 0 times "";
local
var string: word1 is "";
begin
for word1 range listOfSets[1] do
if length(result) = 0 then
result := amb(word1, listOfSets[2 ..]);
end if;
end for;
end func;
const proc: main is func
local
var array string: ambResult is 0 times "";
var string: word is "";
begin
ambResult := amb([] ([] ("the", "that", "a"),
[] ("frog", "elephant", "thing"),
[] ("walked", "treaded", "grows"),
[] ("slowly", "quickly")));
for word range ambResult do
write(word <& " ");
end for;
writeln;
end func;
</lang>
Output:
<pre>
that thing grows slowly
</pre>
=={{Header|SETL}}==
|