HELP: 2all?
{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( ... elt1 elt2 -- ... ? ) } } { "?" boolean } }
-{ $description "Tests the predicate pairwise against elements of " { $snippet "seq1" } " and " { $snippet "seq2" } ". If the sequences have different lengths, then only the smallest sequences items are compared with the other." }
+{ $description "Tests if all pairwise elements of " { $snippet "seq1" } " and " { $snippet "seq2" } " fulfill the predicate. If the sequences have different lengths, then only the smallest sequences items are compared with the other." }
{ $examples
{ $example
"USING: math prettyprint sequences ;"
}
} ;
+HELP: 2any?
+{ $values { "seq1" sequence } { "seq2" sequence } { "quot" { $quotation ( ... elt1 elt2 -- ... ? ) } } { "?" boolean } }
+{ $description "Tests if any pairwise elements of " { $snippet "seq1" } " and " { $snippet "seq2" } " fulfill the predicate. If the sequences have different lengths, then only the smallest sequences items are compared with the other." }
+{ $examples
+ { $example
+ "USING: math prettyprint sequences ;"
+ "{ 2 4 5 8 } { 2 4 6 8 } [ < ] 2any? ."
+ "t"
+ }
+} ;
+
HELP: find
{ $values { "seq" sequence }
{ "quot" { $quotation ( ... elt -- ... ? ) } }
} [ { 11 22 33 } [ + ] BV{ } map-index-as ] unit-test
{ t } [ { } { 99 88 } [ <= ] 2all? ] unit-test
+
+{ f } [ { } { 99 88 } [ <= ] 2any? ] unit-test
+{ t } [ { 2 4 5 8 } { 2 4 6 8 } [ < ] 2any? ] unit-test
+{ f } [ { 2 4 6 8 } { 2 4 6 8 } [ < ] 2any? ] unit-test
: 2all? ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... ? )
(2each) all-integers? ; inline
+: 2any? ( ... seq1 seq2 quot: ( ... elt1 elt2 -- ... ? ) -- ... ? )
+ [ not ] compose 2all? not ; inline
+
: 3each ( ... seq1 seq2 seq3 quot: ( ... elt1 elt2 elt3 -- ... ) -- ... )
(3each) each-integer ; inline