product-find ( ... sequences quot: ( ... seq -- ... ? ) -- ... sequence )
Product sequences

Prev:product-each ( ... sequences quot: ( ... seq -- ... ) -- ... )


Vocabulary
sequences.product

Inputs
sequencesa sequence
quota quotation with stack effect ( ... seq -- ... ? )


Outputs
sequencea sequence


Word description
Calls quot for every element of the cartesian product of sequences, returning the first sequence where the quotation returns a true value.

Notes
[ ... ] product-find is equivalent to, but more efficient than, <product-sequence> [ ... ] find nip.

See also
product-map, product-each

Definition


:: product-find
( ... sequences quot: ( ... seq -- ... ? ) -- ... sequence )
sequences { [ empty? ] [ [ empty? ] any? ] } 1||
[ f ] [
sequences length f <array>
[ sequences >array 0 quot (product-find) ] 1guard
] if ; inline