bake.fry: commas factor

db4
Eduardo Cavazos 2008-07-04 15:22:47 -05:00
parent 54d0cdde4f
commit 12d22e593c
1 changed files with 10 additions and 15 deletions

View File

@ -1,6 +1,7 @@
USING: kernel combinators arrays vectors quotations sequences splitting
parser macros sequences.deep combinators.conditional bake newfx ;
parser macros sequences.deep
combinators.short-circuit combinators.conditional bake newfx ;
IN: bake.fry
@ -53,28 +54,22 @@ DEFER: shallow-fry
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
: bakeable? ( obj -- ? ) { [ array? ] [ vector? ] } 1|| ;
: fry-specifier? ( obj -- ? ) { , @ } member-of? ;
: count-inputs ( quot -- n ) flatten [ fry-specifier? ] count ;
: commas ( n -- seq ) , <repetition> ;
: [fry] ( quot -- quot' )
[
{
{
[ callable? ]
[ [ count-inputs \ , <repetition> ] [ [fry] ] bi append ]
{ [ callable? ] [ [ count-inputs commas ] [ [fry] ] bi append ] }
{ [ bakeable? ] [ [ count-inputs commas ] [ [bake] ] bi append ] }
{ [ drop t ] [ 1quotation ] }
}
{
[ array? ]
[ [ count-inputs \ , <repetition> ] [ [bake] ] bi append ]
}
{
[ vector? ]
[ [ count-inputs \ , <repetition> ] [ [bake] ] bi append ]
}
{ [ drop t ] [ 1quotation ] }
}
1cond
1cond
]
map concat deep-fry ;