Amb: Difference between revisions
Content added Content deleted
m (→version 1: split a one-line DO loop into two statements.) |
|||
Line 2,957: | Line 2,957: | ||
An assumption was made that equivalent lowercase and uppercase (Latin) letters are considered a match. |
An assumption was made that equivalent lowercase and uppercase (Latin) letters are considered a match. |
||
<lang rexx>/*REXX program demonstrates the Amd operator, choosing a word from each set. */ |
<lang rexx>/*REXX program demonstrates the Amd operator, choosing a word from each set. */ |
||
@.=; @.1 = "the that a" |
@.=; @.1 = "the that a" |
||
@.2 = "frog elephant thing" |
@.2 = "frog elephant thing" |
||
@.3 = "walked treaded grows" |
@.3 = "walked treaded grows" |
||
@.4 = "slowly quickly" |
@.4 = "slowly quickly" |
||
call Amb 1 /*find all word combinations that works*/ |
call Amb 1 /*find all word combinations that works*/ |
||
exit /*stick a fork in it, we're all done. */ |
exit /*stick a fork in it, we're all done. */ |
||
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
/*──────────────────────────────────────────────────────────────────────────────────────*/ |
||
Amb: procedure expose @.; parse arg # x; arg . u |
Amb: procedure expose @.; parse arg # x; arg . u /*ARG uppercases U values. */ |
||
do j=1 until @.j=='' |
do j=1 until @.j=='' /*locate a null string. */ |
||
end /*j*/ |
|||
t= j-1 /*define number of sets. */ |
|||
if #>t then do; y=word(u, 1) /*Y: is a uppercased U. */ |
|||
do n=2 to words(u); ?=word(u, n) |
|||
if left(?, 1) \== right(y, 1) then return; y=? |
|||
end /*n*/ |
|||
say space(x) /*¬show superfluous blanks.*/ |
|||
end |
end |
||
do k=1 for words(@.#); call Amb #+1 x word(@.#, k) |
|||
end /*k*/ /* [↑] generate all combs */ |
|||
return /* recursively. */</lang> |
|||
return</lang> |
|||
{{out|output|text= when using the default internal input:}} |
{{out|output|text= when using the default internal input:}} |
||
<pre> |
<pre> |