Amb: Difference between revisions

41 bytes added ,  11 months ago
→‎{{header|REXX}}: exchange versions
mNo edit summary
(→‎{{header|REXX}}: exchange versions)
Line 4,210:
=={{header|REXX}}==
===version 1===
An assumption was made that equivalent lowercase and uppercase (Latin) letters are considered a match,
<br>although that isn't case here for these words &nbsp; (required by this task).
<syntaxhighlight lang="rexx">/*REXX program demonstrates the Amd operator, choosing a word from each set. */
@.1 = "the that a"
@.2 = "frog elephant thing"
@.3 = "walked treaded grows"
@.4 = "slowly quickly"
@.0 = 4 /*define the number of sets being ised.*/
call Amb 1 /*find all word combinations that works*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Amb: procedure expose @.; parse arg # x; arg . u /*ARG uppercases U value. */
if #>@.0 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 strip(x) /*¬show superfluous blanks.*/
end
do j=1 for words(@.#); call Amb #+1 x word(@.#, j) /*gen all combos recursively*/
end /*j*/; return</syntaxhighlight>
{{out|output|text=&nbsp; when using the default internal inputs:}}
<pre>
that thing grows slowly
</pre>
 
===version 2===
<syntaxhighlight lang="rexx"> /* REXX **************************************************************
* 25.08.2013 Walter Pachl derived from PL/I
Line 4,321 ⟶ 4,295:
End
Return</syntaxhighlight>
Output: {{out|output|text=identical to PL/I's i}}
<pre>Input:
the frog walked slowly
that elephant treaded quickly
a thing grows
if trots
 
--> the elephant trots slowly
--> that thing grows slowly
--> if frog grows slowly</pre>
 
===version 2===
An assumption was made that equivalent lowercase and uppercase (Latin) letters are considered a match,
<br>although that isn't case here for these words &nbsp; (required by this task).
<syntaxhighlight lang="rexx">/*REXX program demonstrates the Amd operator, choosing a word from each set. */
@.1 = "the that a"
@.2 = "frog elephant thing"
@.3 = "walked treaded grows"
@.4 = "slowly quickly"
@.0 = 4 /*define the number of sets being ised.*/
call Amb 1 /*find all word combinations that works*/
exit /*stick a fork in it, we're all done. */
/*--------------------------------------------------------------------------------------*/
Amb: procedure expose @.; parse arg # x; arg . u /*ARG uppercases U value. */
if #>@.0 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 strip(x) /*¬show superfluous blanks.*/
end
do j=1 for words(@.#); call Amb #+1 x word(@.#, j) /*gen all combos recursively*/
end /*j*/; return</syntaxhighlight>
{{out|output|text=&nbsp; when using the default internal inputs:}}
<pre>that thing grows slowly</pre>
 
=={{header|Ring}}==
2,295

edits