]> gitweb.factorcode.org Git - factor.git/blob - basis/lists/lazy/lazy-tests.factor
Switch to https urls
[factor.git] / basis / lists / lazy / lazy-tests.factor
1 ! Copyright (C) 2006 Matthew Willis and Chris Double.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: destructors io io.encodings.utf8 io.files kernel lists
4 lists.lazy math sequences tools.test ;
5
6 { { 1 2 3 4 } } [
7   { 1 2 3 4 } >list list>array
8 ] unit-test
9
10 { { { 1 4 } { 1 5 } { 2 4 } { 2 5 } { 3 4 } { 3 5 } } } [
11   { 1 2 3 } >list { 4 5 } >list 2list lcartesian-product* list>array
12 ] unit-test
13
14 { { { 1 4 } { 1 5 } { 2 4 } { 2 5 } { 3 4 } { 3 5 } } } [
15   { 1 2 3 } >list { 4 5 } >list lcartesian-product list>array
16 ] unit-test
17
18 { { 5 6 6 7 7 8 } } [
19   { 1 2 3 } >list { 4 5 } >list 2list [ + ] lcartesian-map list>array
20 ] unit-test
21
22 { { 5 6 7 8 } } [
23   { 1 2 3 } >list { 4 5 } >list 2list { [ drop odd? ] } [ + ] lcartesian-map* list>array
24 ] unit-test
25
26 { { 4 5 6 } } [
27     3 { 1 2 3 } >list [ + ] with lmap-lazy list>array
28 ] unit-test
29
30 { { 1 2 4 8 16 } } [
31   5 1 [ 2 * ] lfrom-by ltake list>array
32 ] unit-test
33
34 [ [ ] lmap ] must-infer
35 [ [ ] lmap>array ] must-infer
36 [ [ drop ] foldr ] must-infer
37 [ [ drop ] foldl ] must-infer
38 [ [ drop ] leach ] must-infer
39 [ lnth ] must-infer
40
41 { { 1 2 3 } } [ { 1 2 3 4 5 } >list [ 2 > ] luntil list>array ] unit-test
42
43 { } [
44     "resource:LICENSE.txt" utf8 <file-reader> [
45         llines list>array drop
46     ] with-disposal
47 ] unit-test
48 { } [
49     "resource:LICENSE.txt" utf8 <file-reader> [
50         lcontents list>array drop
51     ] with-disposal
52 ] unit-test