Anonymous user
Cartesian product of two or more lists: Difference between revisions
Cartesian product of two or more lists (view source)
Revision as of 23:23, 17 May 2019
, 5 years ago→version 1: changes some whitespace and comments.
m (→version 1: changed DO-END comments to match the DO statements.) |
m (→version 1: changes some whitespace and comments.) |
||
Line 2,498:
/* [↓] process each of the @.n values*/
do n=1 while @.n \= '' /*keep processing while there's a value*/
z= translate( space( @.n, 0), , ',')
do #=1 until z=='' /*process each elements in first list. */
parse var z '{' x.# '}' z /*parse the list (contains elements). */
Line 2,507:
do j=i+1 for #-1 /* " " subsequent lists. */
do b=1 for words(x.j) /* " " elements of subsequent list*/
$=$',('word(x.i, a)","word(x.j, b)')' /*append partial
end /*b*/
end /*j*/
end /*a*/
end /*i*/
say 'Cartesian product of ' space(@.n) " is ───► {"substr($, 2)'}'
end /*n
{{out|output|text= when using the default lists:}}
<pre>
|