]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences.generalizations: adding "nall?".
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 27 Sep 2012 18:42:09 +0000 (11:42 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 27 Sep 2012 18:42:09 +0000 (11:42 -0700)
basis/sequences/generalizations/generalizations-docs.factor
basis/sequences/generalizations/generalizations-tests.factor
basis/sequences/generalizations/generalizations.factor

index 9ceff0c6edee6dfa733f2075893d29aee90c8b4b..09e9cad940848f84b15db965c5826045de62d1a0 100644 (file)
@@ -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
index d3655786caf972307e043989cf8f1c4fbcc66179..bdce788615e717885426701b337dfb705110bfeb 100644 (file)
@@ -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
index 8fdb4eec38f18cf0147621a0f62823dabb392715..3a1f8b2784a0a4570beaa02c9a89301d9757b278 100644 (file)
@@ -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