sequences.generalizations: adding "nall?".
parent
608bedd208
commit
3abc7a9500
|
@ -114,6 +114,10 @@ HELP: nmap-reduce
|
|||
{ $values { "map-quot" { $quotation "( element... -- intermediate )" } } { "reduce-quot" { $quotation "( prev intermediate -- next )" } } { "n" integer } }
|
||||
{ $description "A generalization of " { $link map-reduce } " that can be applied to any number of sequences." } ;
|
||||
|
||||
HELP: nall?
|
||||
{ $values { "seqs... " { $snippet "n" } " sequences on the datastack" } { "quot" { $quotation "( element... - ? )" } } { "n" integer } }
|
||||
{ $description "A generalization of " { $link all? } " that can be applied to any number of sequences." } ;
|
||||
|
||||
ARTICLE: "sequences.generalizations" "Generalized sequence words"
|
||||
"The " { $vocab-link "sequences.generalizations" } " vocabulary defines generalized versions of various sequence operations."
|
||||
{ $subsections
|
||||
|
|
|
@ -136,3 +136,7 @@ D4d$
|
|||
{ 45 } [
|
||||
{ 1 2 3 } { 4 5 6 } { 7 8 9 } [ + + ] [ + ] 3 nmap-reduce
|
||||
] unit-test
|
||||
|
||||
{ t } [
|
||||
{ 1 3 5 } { 2 4 6 } { 4 8 12 } [ + + odd? ] 3 nall?
|
||||
] unit-test
|
||||
|
|
|
@ -121,3 +121,6 @@ MACRO: nmap-reduce ( map-quot reduce-quot n -- quot )
|
|||
[ [ first ] _ napply @ 1 ] _ nkeep
|
||||
_ _ (neach) (each-integer)
|
||||
] ;
|
||||
|
||||
: nall? ( seqs... quot n -- )
|
||||
(neach) all-integers? ; inline
|
||||
|
|
Loading…
Reference in New Issue