VocabularycombinatorsInputsobject | an object |
quot | a quotation with stack effect ( ... object(n) -- ... object(n+1) ) |
OutputsWord descriptionApplies the quotation repeatedly with
object as the initial input until the output of the quotation equals the input.
ExamplesUSING: combinators kernel math prettyprint sequences ;
IN: scratchpad
: flatten ( sequence -- sequence' )
"flatten" over index
[ [ 1 + swap nth ] [ nip dup 2 + ] [ drop ] 2tri replace-slice ] when* ;
{ "flatten" { 1 { 2 3 } "flatten" { 4 5 } { 6 } } } [ flatten ] to-fixed-point .
{ 1 { 2 3 } 4 5 { 6 } }
Definition