to-fixed-point ( ... object quot: ( ... object(n) -- ... object(n+1) ) -- ... object(n) )


Vocabulary
combinators

Inputs
objectan object
quota quotation with stack effect ( ... object(n) -- ... object(n+1) )


Outputs
object(n)an object


Word description
Applies the quotation repeatedly with object as the initial input until the output of the quotation equals the input.

Examples
USING: 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


: to-fixed-point
( ... object quot: ( ... object(n) -- ... object(n+1) ) -- ... object(n) )
[ keep over = ] keep [ to-fixed-point ] curry unless ;
inline recursive