> (cons-stream 2 (cons-stream 3 the-empty-stream)) (2 . #) > (cons-stream 2 (cons-stream 3 the-empty-stream)) > s (2 . #) > (head s) 2 > (tail s) (3 . #) > (head (tail s)) 3 > (tail (tail s)) () [image] [image] b: undefined; cannot reference an identifier before its definition > (head s) 2 > (tail s) [image] [image] b: undefined; cannot reference an identifier before its definition > (tail s) [image] [image] b: undefined; cannot reference an identifier before its definition > (define b 42) > (tail s) (42 . #) > > (from-to 1 100) (1 . #) > (from-to 1 (fact 30000)) (1 . #) > (define (from-to a b) (if (> a b) '() (cons a (from-to (+ a 1) b)))) > (length (from-to 1 (fact 30000))) [image] Interactions disabled; out of memory > (length (from-to 1 (fact 30000))) [image] [image] mcdr: contract violation expected: mpair? given: # > (length (from-to 1 (fact 30000))) > (from-to 1 (fact 30000)) [image] Interactions disabled; out of memory > (from-to 1 (fact 30000)) (1 . #) > > (take 10 (enum 1 (fact 100))) (1 2 3 4 5 6 7 8 9 10) > (find-stream (lambda (x) (> x 10)) (enum 1 (fact 100))) (11 . #) > (find-stream (lambda (x) (> x 10)) (enum 1 (fact 100))) (11 . #) > (find-stream (lambda (x) (> x 10)) (from 1)) (11 . #) > (find-stream (lambda (x) (< x 0)) (from 1)) [image] [image] user break > nats (0 . #) > (find-stream (lambda (x) (> x 10)) nats) (11 . #) > (take 10 nats) (0 1 2 3 4 5 6 7 8 9) > (take 10 fibs) (0 1 1 2 3 5 8 13 21 34) > (take 100 fibs) (0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 102334155 165580141 267914296 433494437 701408733 1134903170 1836311903 2971215073 4807526976 7778742049 12586269025 20365011074 32951280099 53316291173 86267571272 139583862445 225851433717 365435296162 591286729879 956722026041 1548008755920 2504730781961 4052739537881 6557470319842 10610209857723 17167680177565 27777890035288 44945570212853 72723460248141 117669030460994 190392490709135 308061521170129 498454011879264 806515533049393 1304969544928657 2111485077978050 3416454622906707 5527939700884757 8944394323791464 14472334024676221 23416728348467685 37889062373143906 61305790721611591 99194853094755497 160500643816367088 259695496911122585 420196140727489673 679891637638612258 1100087778366101931 1779979416004714189 2880067194370816120 4660046610375530309 7540113804746346429 12200160415121876738 19740274219868223167 31940434634990099905 51680708854858323072 83621143489848422977 135301852344706746049 218922995834555169026) > > (map-stream 1+ nats) (1 . #) > (take 10 (map-stream 1+ nats)) (1 2 3 4 5 6 7 8 9 10) > (take 10 (map-stream 1+ fibs)) (1 2 2 3 4 6 9 14 22 35) > (take 10 (filter-stream odd? s)) [image] [image] b: undefined; cannot reference an identifier before its definition > (take 10 (filter-stream odd? nats)) (1 3 5 7 9 11 13 15 17 19) > (take 10 (filter-stream odd? fibs)) (1 1 3 5 13 21 55 89 233 377) > (define (zip-streams > (zip-streams + nats nats) (0 . #) > (take 10 (zip-streams + nats nats)) (0 2 4 6 8 10 12 14 16 18) > ones (1 . #) > (take 10 ones) (1 1 1 1 1 1 1 1 1 1) > (take 10 (zip-streams + ones ones)) (2 2 2 2 2 2 2 2 2 2) > (take 10 (zip-streams + ones nats)) (1 2 3 4 5 6 7 8 9 10) > (take 10 (map-stream 1+ nats)) (1 2 3 4 5 6 7 8 9 10) > (take 10 nats) (0 1 2 3 4 5 6 7 8 9) > > '(+ 5 a) (+ 5 a) > (delay (+ 5 a)) # > (define code '(+ 5 a)) > (set-car! code '-) > code (- 5 a) > (define code2 '(define (f a) code)) > code2 (define (f a) code) > (define code2 (list 'define '(f a) code)) > code (- 5 a) > code2 (define (f a) (- 5 a)) > ones (1 . #) > (take 12493294832948 (enum 1 10)) (1 2 3 4 5 6 7 8 9 10) > (enum 1 10) (1 . #) > (head (take 30 fibs)) [image] [image] map-stream: arity mismatch; the expected number of arguments does not match the given number expected: 2 given: 3 > (head (take 30 fibs)) 0 > (list-ref 29 (take 30 fibs)) [image] [image] zero?: contract violation expected: number? given: (0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229) > (list-ref (take 30 fibs) 29) 514229 > (list-ref (take 300 fibs) 299) 137347080577163115432025771710279131845700275212767467264610201 > ((nondivisors 2) 10) [image] [image] nondivisors: undefined; cannot reference an identifier before its definition > ((nondivisor 2) 10) #f > ((nondivisor 2) 11) #t > > (take 10 pseudoprimes) (2 1 3 5 7 9 11 13 15 17) > (take 10 pseudoprimes) [image] [image] primes: undefined; cannot reference an identifier before its definition > (take 10 pseudoprimes) [image] Interactions disabled; out of memory > (take 10 (sieve nats)) (2 1 3 5 7 9 11 13 15 17) > (take 10 (from 2)) (2 3 4 5 6 7 8 9 10 11) > (take 10 (sieve (from 2))) (2 3 5 7 9 11 13 15 17 19) > (take 10 (sieve (from 2))) (2 3 5 7 9 11 13 15 17 19) > (take 10 (sieve (from 2))) (2 3 5 7 9 11 13 15 17 19) > (take 10 (sieve (from 2))) (2 3 5 7 11 13 17 19 23 29) > (take 50 (sieve (from 2))) (2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149 151 157 163 167 173 179 181 191 193 197 199 211 223 227 229) > (length (take 500 (sieve (from 2)))) 500 > (length (take 500 (sieve (from 2)))) 500 > (length (take 10000 (sieve (from 2)))) [image] [image] user break > (length (take 1000 (sieve (from 2)))) 1000 > (take 10 primes) (2 3 5 7 11 13 17 19 23 29)