combinators.extras: adding swap-when.
parent
6fd908da40
commit
1e1646a691
|
@ -29,3 +29,6 @@ IN: combinators.extras.tests
|
|||
{ 2 5 } [ 1 2 3 4 5 6 [ - - ] 3bi@ ] unit-test
|
||||
|
||||
{ 3 1 } [ 1 2 [ + ] keepd ] unit-test
|
||||
|
||||
[ "1" "123" ] [ "1" "123" [ length ] [ > ] swap-when ] unit-test
|
||||
[ "123" "1" ] [ "1" "123" [ length ] [ < ] swap-when ] unit-test
|
||||
|
|
|
@ -54,3 +54,6 @@ MACRO: smart-plox ( true -- )
|
|||
_ nano-count { 0 } 2dup first-unsafe _ + >=
|
||||
[ 0 swap set-nth-unsafe call ] [ 3drop ] if
|
||||
] ; inline
|
||||
|
||||
: swap-when ( x y quot: ( x -- n ) quot: ( n n -- ? ) -- x' y' )
|
||||
'[ _ _ 2dup _ bi@ @ [ swap ] when ] call ; inline
|
||||
|
|
Loading…
Reference in New Issue