]> gitweb.factorcode.org Git - factor.git/blob - contrib/lazy-lists/lazy.factor
lazy-lists: add LAZY: word
[factor.git] / contrib / lazy-lists / lazy.factor
1 ! Copyright (C) 2004 Chris Double.
2 ! See http://factorcode.org/license.txt for BSD license.
3 !
4 USING: kernel sequences words inference namespaces math parser ;
5 IN: lazy-lists
6
7 : stack-effect-in ( quot word -- n )
8   stack-effect dup [ 
9     nip effect-in length 
10   ] [ 
11     drop infer first 
12   ] if ;
13
14 : make-lazy-quot ( word quot -- quot )
15   [
16     dup , swap stack-effect-in [ \ curry , ] times \ <promise> , 
17   ] [ ] make ;
18
19 : LAZY: ( -- object object object )
20   CREATE dup reset-generic [ dupd make-lazy-quot define-compound ] f ; parsing