JOY  -  compiled at 15:32:32 on Nov 12 2001 (BDW)
Copyright 2001 by Manfred von Thun
usrlib  is loaded
inilib  is loaded
agglib  is loaded
numlib  is loaded
Friday 23-NOV-01 19:43:12

Testing lazy lists in the library lazlib.joy
lazlib  is loaded
numlib  is already loaded
	 
		(* Some lazy lists defined in the library	*) 
	 
	Naturals. 
[0 [1 From]]
	Evens. 
[0 [2 [2 +] From-by]]
	Powers-of-2. 
[1 [2 [2 *] From-by]]
	 
		(* Rest and Drop				*) 
	 
	Naturals. 
[0 [1 From]]
	Naturals Rest. 
[1 [2 From]]
	Naturals Rest Rest. 
[2 [3 From]]
	Naturals 2 Drop. 
[2 [3 From]]
	Naturals 3 Drop. 
[3 [4 From]]
	 
	Ones. 
[1 [1 [] From-by]]
	Ones  Rest. 
[1 [1 [] From-by]]
	Ones  10 Drop. 
[1 [1 [] From-by]]
	 
		(* First, Second, Third, N-th, Take		*) 
	 
	Evens First. 
0
	Evens Second. 
2
	Evens Third. 
4
	Evens 3 N-th. 
4
	Evens 4 N-th. 
6
	Evens 10 Take. 
[0 2 4 6 8 10 12 14 16 18]
	Powers-of-2   5 N-th. 
16
	Powers-of-2  10 N-th. 
512
	Powers-of-2  20 N-th. 
524288
	Powers-of-2  20 Drop. 
[1048576 [2097152 [2 *] From-by]]
	Powers-of-2  21 N-th. 
1048576
	Powers-of-2  10 Take. 
[1 2 4 8 16 32 64 128 256 512]
	Powers-of-2  5 Drop  5 Take. 
[32 64 128 256 512]
	Ones  5 Take. 
[1 1 1 1 1]
	Ones  5 Drop  5 Take. 
[1 1 1 1 1]
	 
		(* user constructed infinite lazy lists		*) 
	 
	1 [1.1 *] From-by. 
[1 [1.1 [1.1 *] From-by]]
	1 [1.1 *] From-by  Rest. 
[1.1 [1.21 [1.1 *] From-by]]
	1 [1.1 *] From-by  Third. 
1.21
	1 [1.1 *] From-by  10 Drop. 
[2.59374 [2.85312 [1.1 *] From-by]]
	1 [1.1 *] From-by  10 N-th. 
2.35795
	1 [1.1 *] From-by  10 Take. 
[1 1.1 1.21 1.331 1.4641 1.61051 1.77156 1.94872 2.14359 2.35795]
	 
	true [not] From-by. 
[true [false [not] From-by]]
	true [not] From-by   Third. 
true
	true [not] From-by   3 Drop. 
[false [true [not] From-by]]
	true [not] From-by  10 Take. 
[true false true false true false true false true false]
	 
	"" ['a swons] From-by  7 Take. 
["" "a" "aa" "aaa" "aaaa" "aaaaa" "aaaaaa"]
	[] [[]  cons] From-by  7 Take. 
[[] [[]] [[[]]] [[[[]]]] [[[[[]]]]] [[[[[[]]]]]] [[[[[[[]]]]]]]]
	 
		(* user constructed finite lazy lists		*) 
	 
	'0 '9 From-to .			(* digits 	*) 
['0 ['1 '9 From-to]]
	'0 '9  From-to  Third. 
'2
	'0 '9  From-to   9 Drop. 
['9 [': '9 From-to]]
	'0 '9  From-to   9 Drop Null. 
false
	'0 '9  From-to  10 Drop. 
[]
	'0 '9  From-to  10 Drop Null. 
true
	'0 '9  From-to   5 Take. 
['0 '1 '2 '3 '4]
	'0 '9  From-to  10 Take. 
['0 '1 '2 '3 '4 '5 '6 '7 '8 '9]
	 
	10 50 [3 +] From-to-by. 
[10 [13 50 [3 +] From-to-by]]
	10 50 [3 +] From-to-by  Third. 
16
		(* Map and Filter				*) 
	 
	Naturals  [dup *] Map    10 Take. 
[0 1 4 9 16 25 36 49 64 81]
	Naturals  [prime] Filter 10 Take. 
[0 1 2 3 5 7 11 13 17 19]
	 
	Naturals  [fib] Map  [3 rem null] Filter  10 Take. 
[0 3 21 144 987 6765 46368 317811 2178309 14930352]
	Naturals  [prime] Filter  [dup *] Map  10 Take. 
[0 1 4 9 25 49 121 169 289 361]
	 
	 
	1000001 From.                       (*     naturals > 1 Million	*) 
[1000001 [1000002 From]]
	1000001 From [prime] Filter.        (*       primes > 1 Million  *) 
[1000003 [[1000004 [1000005 From]] [prime] Filter]]
	1000001 From [prime] Filter Third.  (* third prime  > 1 Million	*) 
1000037
	1000001 From [prime] Filter 50 Take.(* fifty primes > 1 Million	*) 
[1000003 1000033 1000037 1000039 1000081 1000099 1000117 1000121 1000133 1000151 1000159 1000171 1000183 1000187 1000193 1000199 1000211 1000213 1000231 1000249 1000253 1000273 1000289 1000291 1000303 1000313 1000333 1000357 1000367 1000381 1000393 1000397 1000403 1000409 1000423 1000427 1000429 1000453 1000457 1000507 1000537 1000541 1000547 1000577 1000579 1000589 1000609 1000619 1000621 1000639]
	 
	(* END:  laztst.joy *) 
Time:  400000 CPU