Handbook
Glossary
product-map-as ( ... sequences quot: ( ... seq -- ... value ) exemplar -- ... sequence )
Product sequences
Prev:
product-map ( ... sequences quot: ( ... seq -- ... value ) -- ... sequence )
Next:
product-map>assoc ( ... sequences quot: ( ... seq -- ... key value ) exemplar -- ... assoc )
Vocabulary
sequences
.
product
Inputs
sequences
a
sequence
quot
a
quotation
with stack effect
( ... seq -- ... value )
exemplar
a
sequence
Outputs
sequence
a
sequence
Word description
Calls
quot
for every element of the cartesian product of
sequences
and collects the results from
quot
into an output sequence the same type as the
exemplar
sequence.
Definition
USING:
arrays
kernel
math
sequences
sequences.private
sequences.product.private
;
IN:
sequences.product
::
product-map-as
( ... sequences quot: ( ... seq -- ... value ) exemplar -- ... sequence )
sequences
>array
:>
sequences 0 sequences
product-length
exemplar
[|
result |
sequences
[
clone
swap
quot
dip
[
result
set-nth-unsafe
]
[
1
+
]
bi
]
product-each
result
]
new-like
nip
;
inline