1 USING: arrays combinators fry generalizations kernel macros
3 IN: combinators.short-circuit
7 MACRO: keeping ( n quot -- quot' )
9 '[ _ _ nkeep _ nrot ] ;
13 MACRO: n&& ( quots n -- quot )
16 [ '[ drop _ _ keeping dup not ] ]
17 [ drop '[ drop _ ndrop f ] ]
20 ] [ '[ _ nnip ] suffix 1array ] bi
25 : unoptimized-&& ( quots quot -- ? )
26 [ [ call dup ] ] dip call [ nip ] prepose [ f ] 2dip all? swap and ; inline
30 : 0&& ( quots -- ? ) [ ] unoptimized-&& ;
31 : 1&& ( obj quots -- ? ) [ with ] unoptimized-&& ;
32 : 2&& ( obj1 obj2 quots -- ? ) [ 2with ] unoptimized-&& ;
33 : 3&& ( obj1 obj2 obj3 quots -- ? ) [ 3 nwith ] unoptimized-&& ;
35 MACRO: n|| ( quots n -- quot )
38 [ '[ drop _ _ keeping dup ] ]
42 ] [ '[ drop _ ndrop t ] [ f ] 2array suffix 1array ] bi
47 : unoptimized-|| ( quots quot -- ? )
48 [ [ call ] ] dip call map-find drop ; inline
52 : 0|| ( quots -- ? ) [ ] unoptimized-|| ;
53 : 1|| ( obj quots -- ? ) [ with ] unoptimized-|| ;
54 : 2|| ( obj1 obj2 quots -- ? ) [ 2with ] unoptimized-|| ;
55 : 3|| ( obj1 obj2 obj3 quots -- ? ) [ 3 nwith ] unoptimized-|| ;