2 USING: kernel combinators quotations arrays sequences assocs
3 locals generalizations macros fry ;
5 IN: combinators.short-circuit
7 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
9 :: n&&-rewrite ( quots N -- quot )
11 [ '[ drop N ndup @ dup not ] [ drop N ndrop f ] 2array ]
13 [ t ] [ N nnip ] 2array suffix
16 MACRO: 0&& ( quots -- quot ) 0 n&&-rewrite ;
17 MACRO: 1&& ( quots -- quot ) 1 n&&-rewrite ;
18 MACRO: 2&& ( quots -- quot ) 2 n&&-rewrite ;
19 MACRO: 3&& ( quots -- quot ) 3 n&&-rewrite ;
21 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
23 :: n||-rewrite ( quots N -- quot )
25 [ '[ drop N ndup @ dup ] [ N nnip ] 2array ]
27 [ drop N ndrop t ] [ f ] 2array suffix
30 MACRO: 0|| ( quots -- quot ) 0 n||-rewrite ;
31 MACRO: 1|| ( quots -- quot ) 1 n||-rewrite ;
32 MACRO: 2|| ( quots -- quot ) 2 n||-rewrite ;
33 MACRO: 3|| ( quots -- quot ) 3 n||-rewrite ;
35 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!