HELP: lazy-map
{ $values { "list" "a cons object" } { "quot" { $quotation "( obj -- X )" } } { "result" "resulting cons object" } }
-{ $description "Perform a similar functionality to that of the " { $link map } " word, but in a lazy manner. No evaluation of the list elements occurs initially but a " { $link <lazy-map> } " object is returned which conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required." } ;
+{ $description "Perform a similar functionality to that of the " { $link map } " word, but in a lazy manner. No evaluation of the list elements occurs initially but a " { $link <lazy-map-state> } " object is returned which conforms to the list protocol. Calling " { $link car } ", " { $link cdr } " or " { $link nil? } " on this will evaluate elements as required." } ;
HELP: ltake
{ $values { "n" "a non negative integer" } { "list" "a cons object" } { "result" "resulting cons object" } }
: lazy-cons ( car cdr -- promise )
[ T{ promise f f t f } clone ] 2dip
- [ promise ] bi@ \ lazy-cons-state boa
+ [ <promise> ] bi@ \ lazy-cons-state boa
>>value ;
M: lazy-cons-state car ( lazy-cons -- car )
} ;
HELP: cons
-{ $values { "car" "the head of the list cell" } { "cdr" "the tail of the list cell" } { "cons" list } }
+{ $values { "car" "the head of the list cell" } { "cdr" "the tail of the list cell" } { "cons-state" list } }
{ $description "Constructs a cons cell." } ;
HELP: swons