> (qfib 100) 354224848179261915075 > (fib 20) 6765 > (fib 30) 832040 > (fib 32) 2178309 > (delay (fib 32)) # > (define promise (delay (fib 32))) > promise # > (+ 2 4) 6 > (* 3 5) 15 > (force promise) 2178309 > (force promise) 2178309 > (delay (car '())) # > (define error (car '())) [image] [image] mcar: contract violation expected: mpair? given: () > (define error (delay (car '()))) > (force error) [image] [image] mcar: contract violation expected: mpair? given: () > (define l '()) > (car l) [image] [image] mcar: contract violation expected: mpair? given: () > (define first (car l)) [image] [image] mcar: contract violation expected: mpair? given: () > (define first (delay (car l))) > (set! l (list 1 2 3)) > (force first) 1 > (define undefined (delay (car l2))) > (define l2 '( 1 2 3)) > (force undefined) 1 > (delay (car '())) [image] [image] mcar: contract violation expected: mpair? given: () > promise? [image] [image] promise?: undefined; cannot reference an identifier before its definition > (cons-stream 1 (cons-stream 2 (cons-stream 3 the-empty-stream))) > (head s) 1 > (head (tail s)) 2 > (head (head (tail s))) [image] [image] mcar: contract violation expected: mpair? given: 2 > (head (tail (tail s))) 3 > (tail (tail (tail s))) () > (tail s) (2 . #) [image] [image] b: undefined; cannot reference an identifier before its definition > s [image] [image] s: undefined; cannot reference an identifier before its definition > s (1 . #) [image] [image] cons-stream: undefined; cannot reference an identifier before its definition > (delay 1) # > (force 1) [image] [image] application: not a procedure; expected a procedure that can be applied to arguments given: 1 > (delay (fib 32)) # > (define promise (delay (fib 32))) > (force promise) 2178309 > (force promise) 2178309 > (force promise) 2178309 > (define promise (delay (fib 32))) > s (1 . #) > (head (tail s)) 2 > (head (head (tail s))) [image] [image] mcar: contract violation expected: mpair? given: 2 > (head (tail (tail s))) [image] [image] b: undefined; cannot reference an identifier before its definition > (define b 'video) > (head (tail (tail s))) video > (enum 1 100) (1 . #) > (head (tail (tail (enum 1 100)))) 3 > (from-to 1 10) (1 2 3 4 5 6 7 8 9 10) > (enum 1 10) (1 . #) > (length (from 1 10000000)) [image] Interactions disabled; out of memory > (length (from-to 1 1000000)) 1000000 > (enum 1 1000000) (1 . #) > (enum 1 100000000000000) (1 . #) > (take 10 (enum 1 100000000000000)) (1 2 3 4 5 6 7 8 9 10) > (take 10 (enum 1 100000000000000)) > (find-stream odd? (enum 0 100000000)) (1 . #) > (take 10 (from 15)) (15 16 17 18 19 20 21 22 23 24) > (find-stream odd? (from 0)) (1 . #) > (find-stream negative? (from 0)) [image] [image] user break > (find-stream negative? (enum 10 100)) #f > (find-stream negative? (enum 10 1000)) #f > (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 (lambda (x) (+ x 1) > (take 10 (map-stream (lambda (x) (* x x)) nats)) (0 1 4 9 16 25 36 49 64 81) > (take 10 (map-stream (lambda (x) (* x x)) fibs)) (0 1 1 4 9 25 64 169 441 1156) > (take 10 (map-stream (lambda (x) (* x x)) (enum 1 10))) (1 4 9 16 25 36 49 64 81 100) > (take 10 (map-stream (lambda (x) (* x x)) (enum 1 20))) (1 4 9 16 25 36 49 64 81 100) > (take 10 (map-stream (lambda (x) (* x x)) (enum 1 5))) (1 4 9 16 25) > > (take 10 (filter-stream odd? (map-stream (lambda (x) (* x x)) nats))) (1 9 25 49 81 121 169 225 289 361) > (map + '(1 2 3) '(4 5 6)) (5 7 9) > (take 10 (zip-stream + nats nats)) (0 2 4 6 8 10 12 14 16 18) > (take 10 (map-stream + nats nats)) (0 2 4 6 8 10 12 14 16 18) > (take 10 (map-stream + nats nats nats nats nats)) (0 5 10 15 20 25 30 35 40 45) > (cons-stream 1 a) (1 . #) > a [image] [image] a: undefined; cannot reference an identifier before its definition > (define a 2) > (define a nats) > (take 10 ones) [image] [image] ones: undefined; cannot reference an identifier before its definition > (take 10 ones) (1 1 1 1 1 1 1 1 1 1) > (take 10 nats) (0 1 2 3 4 5 6 7 8 9) > (head (tail nats)) 1 [image] define: not allowed in an expression context in: (define tail (r5rs:lambda (nats2) (map-stream + nats2 ones))) > (take 10 fibs) (0 1 1 2 3 5 8 13 21 34) > (take 100 fibs) [image] [image] user break > (take 20 fibs) (0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181) > (take 30 fibs) [image] Interactions disabled; out of memory > (take 30 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) > (take 10 (from 2)) (2 3 4 5 6 7 8 9 10 11) > (sieve (from 2)) (2 . #) > ((not-divisible 2) 4) > (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 100 (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 233 239 241 251 257 263 269 271 277 281 283 293 307 311 313 317 331 337 347 349 353 359 367 373 379 383 389 397 401 409 419 421 431 433 439 443 449 457 461 463 467 479 487 491 499 503 509 521 523 541) >