combinators.conditional: 1if and 1cond

db4
Eduardo Cavazos 2008-06-30 10:35:09 -05:00
parent 6bf04eb1ee
commit 46fc50af37
1 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
USING: kernel combinators sequences macros fry newfx combinators.cleave ;
IN: combinators.conditional
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MACRO: 1if ( test then else -- ) '[ dup @ , , if ] ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
MACRO: 1cond ( tbl -- )
[ [ 1st [ dup ] prepend ] [ 2nd ] bi {2} ] map
[ cond ] prefix-on ;
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!