Another recursive fry fi
parent
1c10cb0ff1
commit
b91a314f0e
|
|
@ -52,3 +52,13 @@ sequences ;
|
||||||
[ { 1 { 2 { 3 } } } ] [
|
[ { 1 { 2 { 3 } } } ] [
|
||||||
1 2 3 '[ , [ , [ , 1array ] call 2array ] call 2array ] call
|
1 2 3 '[ , [ , [ , 1array ] call 2array ] call 2array ] call
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
{ 1 1 } [ '[ [ [ , ] ] ] ] must-infer-as
|
||||||
|
|
||||||
|
[ { { { 3 } } } ] [
|
||||||
|
3 '[ [ [ , 1array ] call 1array ] call 1array ] call
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ { { { 3 } } } ] [
|
||||||
|
3 '[ [ [ , 1array ] call 1array ] call 1array ] call
|
||||||
|
] unit-test
|
||||||
|
|
|
||||||
|
|
@ -46,15 +46,22 @@ DEFER: (shallow-fry)
|
||||||
shallow-fry
|
shallow-fry
|
||||||
] if* ;
|
] if* ;
|
||||||
|
|
||||||
|
: fry-specifier? ( obj -- ? ) { , namespaces:, @ } member? ;
|
||||||
|
|
||||||
|
: count-inputs ( quot -- n )
|
||||||
|
[
|
||||||
|
{
|
||||||
|
{ [ dup callable? ] [ count-inputs ] }
|
||||||
|
{ [ dup fry-specifier? ] [ drop 1 ] }
|
||||||
|
[ drop 0 ]
|
||||||
|
} cond
|
||||||
|
] map sum ;
|
||||||
|
|
||||||
: fry ( quot -- quot' )
|
: fry ( quot -- quot' )
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
dup callable? [
|
dup callable? [
|
||||||
[
|
[ count-inputs \ , <repetition> % ] [ fry % ] bi
|
||||||
[ { , namespaces:, @ } member? ] filter length
|
|
||||||
\ , <repetition> %
|
|
||||||
]
|
|
||||||
[ fry % ] bi
|
|
||||||
] [ namespaces:, ] if
|
] [ namespaces:, ] if
|
||||||
] each
|
] each
|
||||||
] [ ] make deep-fry ;
|
] [ ] make deep-fry ;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue