]> gitweb.factorcode.org Git - factor.git/blob - extra/lists/lazy/examples/examples.factor
f85344651d1e153f328e88ad358c57cc2ca9c9ee
[factor.git] / extra / lists / lazy / examples / examples.factor
1 ! Rewritten by Matthew Willis, July 2006
2 ! Copyright (C) 2004 Chris Double.
3 ! See http://factorcode.org/license.txt for BSD license.
4
5 USING: lists.lazy math kernel sequences quotations ;
6 IN: lists.lazy.examples
7
8 : naturals 0 lfrom ;
9 : positives 1 lfrom ;
10 : evens 0 [ 2 + ] lfrom-by ;
11 : odds 1 lfrom [ 2 mod 1 = ] lfilter ;
12 : powers-of-2 1 [ 2 * ] lfrom-by ;
13 : ones 1 [ ] lfrom-by ;
14 : squares naturals [ dup * ] lazy-map ;
15 : first-five-squares 5 squares ltake list>array ;