diff --git a/extra/combinators/lib/lib-docs.factor b/extra/combinators/lib/lib-docs.factor index 355d5647df..230d52c1b1 100755 --- a/extra/combinators/lib/lib-docs.factor +++ b/extra/combinators/lib/lib-docs.factor @@ -51,6 +51,6 @@ HELP: && { $values { "quots" "a sequence of quotations with stack effect " { $snippet "( ... -- ... ? )" } } { "?" "a boolean" } } { $description "Calls each quotation in turn; outputs " { $link f } " if one of the quotations output " { $link f } ", otherwise outputs " { $link t } ". As soon as a quotation outputs " { $link f } ", evaluation stops and subsequent quotations are not called." } ; -HELP: || -{ $values { "quots" "a sequence of quotations with stack effect " { $snippet "( ... -- ... ? )" } } { "?" "a boolean" } } -{ $description "Calls each quotation in turn; outputs " { $link t } " if one of the quotations output " { $link t } ", otherwise outputs " { $link f } ". As soon as a quotation outputs " { $link t } ", evaluation stops and subsequent quotations are not called." } ; +! HELP: || +! { $values { "quots" "a sequence of quotations with stack effect " { $snippet "( ... -- ... ? )" } } { "?" "a boolean" } } +! { $description "Calls each quotation in turn; outputs " { $link t } " if one of the quotations output " { $link t } ", otherwise outputs " { $link f } ". As soon as a quotation outputs " { $link t } ", evaluation stops and subsequent quotations are not called." } ; diff --git a/extra/combinators/lib/lib.factor b/extra/combinators/lib/lib.factor index 3976b36cb9..a838b246e4 100755 --- a/extra/combinators/lib/lib.factor +++ b/extra/combinators/lib/lib.factor @@ -63,34 +63,68 @@ MACRO: napply ( n -- ) ! short circuiting words ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -: short-circuit ( quots quot default -- quot ) - 1quotation -rot { } map>assoc alist>quot ; +! : short-circuit ( quots quot default -- quot ) +! 1quotation -rot { } map>assoc alist>quot ; -MACRO: && ( quots -- ? ) - [ [ not ] append [ f ] ] t short-circuit ; +! MACRO: && ( quots -- ? ) +! [ [ not ] append [ f ] ] t short-circuit ; -MACRO: <-&& ( quots -- ) - [ [ dup ] prepend [ not ] append [ f ] ] t short-circuit - [ nip ] append ; +! MACRO: <-&& ( quots -- ) +! [ [ dup ] prepend [ not ] append [ f ] ] t short-circuit +! [ nip ] append ; -MACRO: <--&& ( quots -- ) - [ [ 2dup ] prepend [ not ] append [ f ] ] t short-circuit - [ 2nip ] append ; +! MACRO: <--&& ( quots -- ) +! [ [ 2dup ] prepend [ not ] append [ f ] ] t short-circuit +! [ 2nip ] append ; ! or -MACRO: || ( quots -- ? ) [ [ t ] ] f short-circuit ; +! MACRO: || ( quots -- ? ) [ [ t ] ] f short-circuit ; -MACRO: 0|| ( quots -- ? ) [ [ t ] ] f short-circuit ; +! MACRO: 0|| ( quots -- ? ) [ [ t ] ] f short-circuit ; -MACRO: 1|| ( quots -- ? ) - [ [ dup ] prepend [ t ] ] f short-circuit [ nip ] append ; +! MACRO: 1|| ( quots -- ? ) +! [ [ dup ] prepend [ t ] ] f short-circuit [ nip ] append ; -MACRO: 2|| ( quots -- ? ) - [ [ 2dup ] prepend [ t ] ] f short-circuit [ 2nip ] append ; +! MACRO: 2|| ( quots -- ? ) +! [ [ 2dup ] prepend [ t ] ] f short-circuit [ 2nip ] append ; -MACRO: 3|| ( quots -- ? ) - [ [ 3dup ] prepend [ t ] ] f short-circuit [ 3nip ] append ; +! MACRO: 3|| ( quots -- ? ) +! [ [ 3dup ] prepend [ t ] ] f short-circuit [ 3nip ] append ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +MACRO: 0&& ( quots -- quot ) + [ '[ drop @ dup not ] [ drop f ] 2array ] map + { [ t ] [ ] } suffix + '[ f , cond ] ; + +MACRO: 1&& ( quots -- quot ) + [ '[ drop dup @ dup not ] [ drop drop f ] 2array ] map + { [ t ] [ nip ] } suffix + '[ f , cond ] ; + +MACRO: 2&& ( quots -- quot ) + [ '[ drop 2dup @ dup not ] [ drop 2drop f ] 2array ] map + { [ t ] [ 2nip ] } suffix + '[ f , cond ] ; + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +MACRO: 0|| ( quots -- quot ) + [ '[ drop @ dup ] [ ] 2array ] map + { [ drop t ] [ f ] } suffix + '[ f , cond ] ; + +MACRO: 1|| ( quots -- quot ) + [ '[ drop dup @ dup ] [ nip ] 2array ] map + { [ drop drop t ] [ f ] } suffix + '[ f , cond ] ; + +MACRO: 2|| ( quots -- quot ) + [ '[ drop 2dup @ dup ] [ 2nip ] 2array ] map + { [ drop 2drop t ] [ f ] } suffix + '[ f , cond ] ; ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ifte