lazy-cons ( car cdr -- lazy ) (original) (raw)

Vocabulary
lists.lazy

Inputs

car a quotation with stack effect ( -- elt )
cdr a quotation with stack effect ( -- cons )

Outputs

lazy the resulting cons object

Word description
Constructs a cons object for a lazy list from two quotations. The car quotation should return the head of the list, and the cons quotation the tail when called. When cons or cdr are called on the lazy-cons object then the appropriate quotation is called.

See also
cons, car, cdr, nil, nil?

Definition

USING: kernel lazy ;

IN: lists.lazy

: lazy-cons ( car cdr -- lazy )
[ ] bi@ ;