bake.fry: commas factor
parent
54d0cdde4f
commit
12d22e593c
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
USING: kernel combinators arrays vectors quotations sequences splitting
|
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
|
IN: bake.fry
|
||||||
|
|
||||||
|
@ -53,28 +54,22 @@ DEFER: shallow-fry
|
||||||
|
|
||||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
: bakeable? ( obj -- ? ) { [ array? ] [ vector? ] } 1|| ;
|
||||||
|
|
||||||
: fry-specifier? ( obj -- ? ) { , @ } member-of? ;
|
: fry-specifier? ( obj -- ? ) { , @ } member-of? ;
|
||||||
|
|
||||||
: count-inputs ( quot -- n ) flatten [ fry-specifier? ] count ;
|
: count-inputs ( quot -- n ) flatten [ fry-specifier? ] count ;
|
||||||
|
|
||||||
|
: commas ( n -- seq ) , <repetition> ;
|
||||||
|
|
||||||
: [fry] ( quot -- quot' )
|
: [fry] ( quot -- quot' )
|
||||||
[
|
[
|
||||||
{
|
|
||||||
{
|
{
|
||||||
[ callable? ]
|
{ [ callable? ] [ [ count-inputs commas ] [ [fry] ] bi append ] }
|
||||||
[ [ count-inputs \ , <repetition> ] [ [fry] ] bi append ]
|
{ [ bakeable? ] [ [ count-inputs commas ] [ [bake] ] bi append ] }
|
||||||
|
{ [ drop t ] [ 1quotation ] }
|
||||||
}
|
}
|
||||||
{
|
1cond
|
||||||
[ array? ]
|
|
||||||
[ [ count-inputs \ , <repetition> ] [ [bake] ] bi append ]
|
|
||||||
}
|
|
||||||
{
|
|
||||||
[ vector? ]
|
|
||||||
[ [ count-inputs \ , <repetition> ] [ [bake] ] bi append ]
|
|
||||||
}
|
|
||||||
{ [ drop t ] [ 1quotation ] }
|
|
||||||
}
|
|
||||||
1cond
|
|
||||||
]
|
]
|
||||||
map concat deep-fry ;
|
map concat deep-fry ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue