Merge branch 'master' of git://github.com/littledan/Factor
commit
5810987f13
|
@ -1,4 +1,4 @@
|
||||||
USING: kernel math tools.test combinators.short-circuit ;
|
USING: kernel math tools.test combinators.short-circuit accessors ;
|
||||||
IN: combinators.short-circuit.tests
|
IN: combinators.short-circuit.tests
|
||||||
|
|
||||||
[ 3 ] [ { [ 1 ] [ 2 ] [ 3 ] } 0&& ] unit-test
|
[ 3 ] [ { [ 1 ] [ 2 ] [ 3 ] } 0&& ] unit-test
|
||||||
|
@ -23,3 +23,18 @@ IN: combinators.short-circuit.tests
|
||||||
|
|
||||||
[ 30 ] [ 10 20 compiled-|| ] unit-test
|
[ 30 ] [ 10 20 compiled-|| ] unit-test
|
||||||
[ 2 ] [ 1 1 compiled-|| ] unit-test
|
[ 2 ] [ 1 1 compiled-|| ] unit-test
|
||||||
|
|
||||||
|
! && and || should be row-polymorphic both when compiled and when interpreted
|
||||||
|
|
||||||
|
: row-&& ( -- ? )
|
||||||
|
f t { [ drop dup ] } 1&& nip ;
|
||||||
|
|
||||||
|
[ f ] [ row-&& ] unit-test
|
||||||
|
[ f ] [ \ row-&& def>> call ] unit-test
|
||||||
|
|
||||||
|
: row-|| ( -- ? )
|
||||||
|
f t { [ drop dup ] } 1|| nip ;
|
||||||
|
|
||||||
|
[ f ] [ row-|| ] unit-test
|
||||||
|
[ f ] [ \ row-|| def>> call ] unit-test
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
USING: kernel combinators quotations arrays sequences assocs
|
USING: kernel combinators quotations arrays sequences assocs
|
||||||
generalizations macros fry ;
|
generalizations macros fry math ;
|
||||||
IN: combinators.short-circuit
|
IN: combinators.short-circuit
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
|
||||||
|
MACRO: keeping ( n quot -- quot' )
|
||||||
|
swap dup 1 +
|
||||||
|
'[ _ _ nkeep _ nrot ] ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
MACRO: n&& ( quots n -- quot )
|
MACRO: n&& ( quots n -- quot )
|
||||||
[
|
[
|
||||||
[ [ f ] ] 2dip swap [
|
[ [ f ] ] 2dip swap [
|
||||||
[ '[ drop _ ndup @ dup not ] ]
|
[ '[ drop _ _ keeping dup not ] ]
|
||||||
[ drop '[ drop _ ndrop f ] ]
|
[ drop '[ drop _ ndrop f ] ]
|
||||||
2bi 2array
|
2bi 2array
|
||||||
] with map
|
] with map
|
||||||
|
@ -27,7 +35,7 @@ PRIVATE>
|
||||||
MACRO: n|| ( quots n -- quot )
|
MACRO: n|| ( quots n -- quot )
|
||||||
[
|
[
|
||||||
[ [ f ] ] 2dip swap [
|
[ [ f ] ] 2dip swap [
|
||||||
[ '[ drop _ ndup @ dup ] ]
|
[ '[ drop _ _ keeping dup ] ]
|
||||||
[ drop '[ _ nnip ] ]
|
[ drop '[ _ nnip ] ]
|
||||||
2bi 2array
|
2bi 2array
|
||||||
] with map
|
] with map
|
||||||
|
|
Loading…
Reference in New Issue