2008-06-24 11:39:50 -04:00
|
|
|
USING: kernel combinators quotations arrays sequences assocs
|
2008-11-21 05:00:28 -05:00
|
|
|
locals generalizations macros fry ;
|
2008-06-24 09:35:06 -04:00
|
|
|
IN: combinators.short-circuit
|
|
|
|
|
2008-11-21 05:00:28 -05:00
|
|
|
MACRO:: n&& ( quots n -- quot )
|
2008-11-26 02:00:23 -05:00
|
|
|
[ f ] quots [| q |
|
|
|
|
n
|
|
|
|
[ q '[ drop _ ndup @ dup not ] ]
|
|
|
|
[ '[ drop _ ndrop f ] ]
|
|
|
|
bi 2array
|
|
|
|
] map
|
|
|
|
n '[ _ nnip ] suffix 1array
|
2008-11-21 05:36:18 -05:00
|
|
|
[ cond ] 3append ;
|
2008-11-21 05:00:28 -05:00
|
|
|
|
2009-07-18 04:33:45 -04:00
|
|
|
: 0&& ( quots -- ? ) [ call ] all? ;
|
|
|
|
: 1&& ( obj quots -- ? ) [ call ] with all? ;
|
|
|
|
: 2&& ( obj quots -- ? ) [ call ] with with all? ;
|
|
|
|
: 3&& ( obj quots -- ? ) [ call ] with with with all? ;
|
2008-11-21 05:00:28 -05:00
|
|
|
|
|
|
|
MACRO:: n|| ( quots n -- quot )
|
2008-11-26 02:00:23 -05:00
|
|
|
[ f ] quots [| q |
|
|
|
|
n
|
|
|
|
[ q '[ drop _ ndup @ dup ] ]
|
|
|
|
[ '[ _ nnip ] ]
|
|
|
|
bi 2array
|
|
|
|
] map
|
|
|
|
n '[ drop _ ndrop t ] [ f ] 2array suffix 1array
|
2008-11-21 05:36:18 -05:00
|
|
|
[ cond ] 3append ;
|
2008-11-21 05:00:28 -05:00
|
|
|
|
2009-07-18 04:33:45 -04:00
|
|
|
: 0|| ( quots -- ? ) [ call ] any? ;
|
|
|
|
: 1|| ( obj quots -- ? ) [ call ] with any? ;
|
|
|
|
: 2|| ( obj quots -- ? ) [ call ] with with any? ;
|
|
|
|
: 3|| ( obj quots -- ? ) [ call ] with with with any? ;
|
|
|
|
|