Amb: Difference between revisions

Content added Content deleted
m (→‎version 1: optimized AMB function, changed whitespace.)
Line 2,999: Line 2,999:
/*──────────────────────────────────────────────────────────────────────────────────────*/
/*──────────────────────────────────────────────────────────────────────────────────────*/
Amb: procedure expose @.; parse arg # x; arg . u /*ARG uppercases U values. */
Amb: procedure expose @.; parse arg # x; arg . u /*ARG uppercases U values. */
do j=1 until @.j=='' /*locate a null string. */
do j=1 until @.j=='' /*locate a null string. */
end /*j*/
end /*j*/ /*define number of sets. */
t= j-1 /*define number of sets. */
if #>j-1 then do; y=word(u, 1) /*Y: is a uppercased U. */
if #>t then do; y=word(u, 1) /*Y: is a uppercased U. */
do n=2 to words(u); ?=word(u, n)
do n=2 to words(u); ?=word(u, n)
if left(?, 1) \== right(y, 1) then return; y=?
if left(?, 1) \== right(y, 1) then return; y=?
end /*n*/
end /*n*/
say space(x) /*¬show superfluous blanks.*/
say space(x) /*¬show superfluous blanks.*/
end
end


do k=1 for words(@.#); call Amb #+1 x word(@.#, k)
do k=1 for words(@.#); call Amb #+1 x word(@.#, k)
end /*k*/ /* [↑] generate all combs */
end /*k*/ /* [↑] generate all combs */
return /* recursively. */</lang>
return /* recursively. */</lang>
{{out|output|text=&nbsp; when using the default internal input:}}
{{out|output|text=&nbsp; when using the default internal inputs:}}
<pre>
<pre>
that thing grows slowly
that thing grows slowly