eliminate more redundant empty quots from fry code generation

db4
Joe Groff 2009-11-07 21:50:45 -06:00
parent 972a63630f
commit f9a9a206f2
1 changed files with 14 additions and 4 deletions

View File

@ -74,14 +74,24 @@ INSTANCE: fried-callable fried
[ >quotation make-curry ] if
] if-empty ;
: prune-curries ( seq -- seq' )
dup [ empty? not ] find
[ [ 1 + tail ] dip but-last prefix ]
[ 2drop { } ] if* ;
: convert-curries ( seq -- tail seq' )
unclip-slice [ 0 swap [ convert-curry ] map ] [ >quotation 1quotation ] bi* prefix ;
unclip-slice [ 0 swap [ convert-curry ] map ] dip
[ prune-curries ]
[ >quotation 1quotation prefix ] if-empty ;
: mark-composes ( quot -- quot' )
[ dup \ @ = [ drop [ _ @ ] ] [ 1quotation ] if ] map concat ; inline
: shallow-fry ( quot -- quot' )
check-fry
[ dup \ @ = [ drop [ _ @ ] ] [ 1quotation ] if ] map concat
check-fry mark-composes
{ _ } split convert-curries
spread>quot swap [ [ ] (make-curry) compose ] unless-zero ;
[ [ [ ] ] [ [ ] (make-curry) but-last ] if-zero ]
[ spread>quot swap [ [ ] (make-curry) compose ] unless-zero ] if-empty ;
DEFER: dredge-fry