The (aux stream) modules

Streams, streams after SICP, and sequences and power series

(aux stream): naturals, Fibonacci numbers and primes

test/stream/nats: pass

(define (test/stream/nats _)
  (let1 (nats (take§ 20 (nats§ 0)))
        (⊦= '(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)
            (§->list nats))))
((eta 0.0) (memory #(6291456 1944752 1048576)) (stdout "") (stderr ""))

test/stream/fibs: pass

(define (test/stream/fibs _)
  (let1 (fibs (take§ 20 (fibs§ 0 1)))
        (⊦= '(0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181)
            (§->list fibs))))
((eta 0.0) (memory #(6291456 1957576 1048576)) (stdout "") (stderr ""))

test/stream/ones: pass

(define (test/stream/ones _)
  (let1 (ones (take§ 20 (const§ 1)))
        (⊦= '(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) (§->list ones))))
((eta 0.0) (memory #(6291456 1961248 1048576)) (stdout "") (stderr ""))

test/stream/primes: pass

(define (test/stream/primes _)
  (let1 (primes (take§ 20 primes§))
        (⊦= '(2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71)
            (§->list primes))))
((eta 0.001) (memory #(6291456 2003384 1048576)) (stdout "") (stderr ""))

test/stream/long-prefixes: pass

(define (test/stream/long-prefixes _)
  (⊦= 9999 (list-ref (§->list (take§ 10000 (nats§ 0))) 9999))
  (⊦= 541 (list-ref (§->list (take§ 100 primes§)) 99)))
((eta 0.111) (memory #(12582912 2336512 1048576)) (stdout "") (stderr ""))

test/stream/ones+τ: pass

(define (test/stream/ones+τ _)
  (let1 (ones (take§ 20 (thunk§ 1)))
        (⊦= '(1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) (§->list ones))))
((eta 0.0) (memory #(12582912 2337760 1048576)) (stdout "") (stderr ""))

(aux stream sicp): streams, after SICP

test/stream-sicp/list-roundtrip: pass

(define (test/stream-sicp/list-roundtrip _)
  (⊦≡ '(a b c d) ((compose stream:->list list->stream) '(a b c d))))
((eta 0.0) (memory #(12582912 3107776 1048576)) (stdout "") (stderr ""))

test/stream-sicp/dest-car+cdr: pass

(define (test/stream-sicp/dest-car+cdr _)
  (let* ((n 0)
         (s (λ () (set! n (add1 n)) (δ (δ (|:\x207a;| 1 2 stream:empty))))))
    (⊦≡ '(1 1) (stream:dest/car+cdr (s) ((a d) (list a n)) (else 'empty))))
  (⊦≡ 'empty (stream:dest/car+cdr (δ stream:empty) ((a d) a) (else 'empty)))
  (⊦≡ '(7 7) (stream:dest/car+cdr (δ 7) ((a d) (list a d)) (else 'empty))))
((eta 0.0) (memory #(12582912 3109168 1048576)) (stdout "") (stderr ""))

test/stream-sicp/ref: pass

(define (test/stream-sicp/ref _)
  (⊦≡ 0 ((stream:ref 0) series:range/0-9))
  (⊦≡ 5 ((stream:ref 5) series:range/0-9))
  (⊦≡ 9 ((stream:ref 9) series:range/0-9))
  (⊨ (condition-case (begin ((stream:ref 10) series:range/0-9) #f) ((exn) #t)))
  (⊨ (condition-case
       (begin ((stream:ref 101) series:range/0-9) #f)
       ((exn) #t))))
((eta 0.0) (memory #(12582912 3116312 1048576)) (stdout "") (stderr ""))

test/stream-sicp/take-basics: pass

(define (test/stream-sicp/take-basics _)
  (⊦≡ '(3 4 5 6 7) ((list○take 5) (series:from 3)))
  (⊦≡ '(1 1 1 1 1 1 1 1 1 1) ((list○take 10) stream:1s))
  (⊦≡ '(0 1 2 3 4 5 6 7 8 9) ((list○take 10) numbers/nats))
  (⊦≡ '(0 1 2 3 4 5 6 7 8 9)
      ((list○take 10) ((stream:append-map list) numbers/nats)))
  (⊦≡ 117 ((stream:ref 100) ((not-multiples-of 7) numbers/nats)))
  (⊦≡ '(0 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190)
      ((list○take 20) numbers/triangular))
  (⊦≡ '(0 1 3 6 10 15 21 28 36 45 55 66 78 91 105 120 136 153 171 190)
      ((list○take 20) numbers/triangular/∞))
  (⊦≡ 78 ((stream:ref 6) (evens numbers/triangular)))
  (⊦≡ '(0 10 15 45 55 105 120 190)
      ((list○take 8) ((multiples-of 5) numbers/triangular))))
((eta 0.0) (memory #(12582912 3120056 1048576)) (stdout "") (stderr ""))

test/stream-sicp/zip: pass

(define (test/stream-sicp/zip _)
  (⊦≡ '((0 0 0)
        (1 1 1)
        (2 1 3)
        (3 2 6)
        (4 3 10)
        (5 5 15)
        (6 8 21)
        (7 13 28)
        (8 21 36)
        (9 34 45))
      ((list○take 10)
       (stream:zip numbers/nats numbers/fibonacci numbers/triangular)))
  (⊦≡ '(11 22)
      ((list○take 5)
       ((stream:zip-with +) (list->stream '(1 2)) (list->stream '(10 20)))))
  (⊦≡ '(101 102 103)
      ((list○take 5)
       ((stream:zip-with +) (list->stream '(1 2 3)) (stream:repeat 100))))
  (⊦≡ '() (stream:->list (stream:zip (list->stream '(1 2 3)) stream:empty)))
  (⊦≡ '(11 2 3)
      (stream:->list
        ((stream:zip-with + #:pad 0)
         (list->stream '(1 2 3))
         (list->stream '(10)))))
  (⊦≡ '((1 a) (#f b))
      (stream:->list
        ((stream:zip-with list #:pad #f)
         (list->stream '(1))
         (list->stream '(a b)))))
  (⊦≡ '()
      (stream:->list ((stream:zip-with + #:pad 0) stream:empty stream:empty))))
((eta 0.0) (memory #(12582912 3121568 1048576)) (stdout "") (stderr ""))

test/stream-series/finite-polynomials: pass

(define (test/stream-series/finite-polynomials _)
  (⊦≡ '(2 2 3)
      (stream:->list (series:+ (list->stream '(1 2 3)) (list->stream '(1)))))
  (⊦≡ '(0 1 2 -1 -1)
      (stream:->list
        (series:- (list->stream '(1 2 3)) (list->stream '(1 1 1 1 1)))))
  (⊦≡ '(1 2 1)
      (stream:->list (series:× (list->stream '(1 1)) (list->stream '(1 1)))))
  (⊦≡ '(1 2 2 1)
      (stream:->list (series:× (list->stream '(1 1 1)) (list->stream '(1 1)))))
  (⊦≡ '(1 3 3 1 0 0) ((list○take 6) ((series:expt 3) (list->stream '(1 1)))))
  (⊦≡ '(1 2 2 2 2 2)
      ((list○take 6) (series:× (list->stream '(1 1)) stream:1s)))
  (⊦≡ '(1 1 1 1 1 1)
      ((list○take 6) (series:/ (list->stream '(1)) (list->stream '(1 -1)))))
  (⊦≡ '(1 1 1 1 1 1) ((list○take 6) (series:⁻¹ (list->stream '(1 -1)))))
  (⊦≡ '(1 1 1/2 1/6 1/24 1/120)
      ((list○take 6) (series:exp (list->stream '(0 1)))))
  (⊦≡ '(1 0 0 0) ((list○take 4) (series:exp stream:empty)))
  (⊦≡ '(2 1/4 -1/64 1/512 -5/16384)
      ((list○take 5) (series:√/∞ (list->stream '(4 1)))))
  (⊦≡ '(0 0 0 0) ((list○take 4) (series:√/∞ stream:empty)))
  (⊦≡ '(0 0 0 0) ((list○take 4) (series:√/∞ (list->stream '(0)))))
  (⊦≡ '(0 0 0 0) ((list○take 4) (series:√/∞ (list->stream '(0 0)))))
  (⊦≡ '(0 1 0 0) ((list○take 4) (series:√/∞ (list->stream '(0 0 1)))))
  (⊦≡ '(1 1/2 1/8 0 -1/128 0)
      (letdelay
        ((S (series:√/∞ (series:+ stream:1 (stream:cons 0 S)))))
        ((list○take 6) S)))
  (⊦≡ '(1 -1 1/2 0 -1/8 0)
      (letdelay
        ((T (series:√/∞ (series:- stream:1 (stream:cons 0 ((series:* 2) T))))))
        ((list○take 6) T)))
  (⊦≡ '((1) (1 1) (0 2 1) (0 2 3 1) (0 2 5 4 1))
      ((list○take 5) (riordan-array (list->stream '(1 1)) stream:1s)))
  (⊦≡ ((list○take 5) (riordan-array (list->poly '(1 1)) stream:1s))
      ((list○take 5) (riordan-array (list->stream '(1 1)) stream:1s)))
  (⊦≡ ((list○take 6) (riordan-array (list->poly '(1)) (list->poly '(0 1 1))))
      ((list○take 6)
       (riordan-array (list->stream '(1)) (list->stream '(0 1 1)))))
  (⊦≡ '((1) (1 0) (1 0 0) (1 0 0 0))
      ((list○take 4) (riordan-array stream:1s stream:empty)))
  (⊦≡ '((0) (0 0) (0 0 0) (0 0 0 0))
      ((list○take 4) (riordan-array stream:empty stream:1s))))
((eta 0.001) (memory #(12582912 3120928 1048576)) (stdout "") (stderr ""))

test/stream-sicp/foldr-laziness: pass

(define (test/stream-sicp/foldr-laziness _)
  (⊦≡ 'hello
      ((stream:foldr (λ (a rest) (and a (force rest))) (λ () 'hello))
       (|:\x207a;| #t #t #t stream:empty)))
  (⊦≡ #f
      ((stream:foldr (λ (a rest) (and a (force rest))) (λ () (list (/ 1 0))))
       (|:\x207a;| #t #t #t #f #t stream:0s))))
((eta 0.0) (memory #(12582912 3121000 1048576)) (stdout "") (stderr ""))

test/stream-sicp/mplus-and-iterator: pass

(define (test/stream-sicp/mplus-and-iterator _)
  (⊦≡ '(0 1 2 0 1 2 0 1 2 0)
      ((list○take 10)
       (stream:§ (stream:repeat 0) (stream:repeat 1) (stream:repeat 2))))
  (let ((next (stream:iterator numbers/nats)))
    (⊦≡ '(0 1 2 3)
        (collect-values (λ () (values (next) (next) (next) (next)))))))
((eta 0.0) (memory #(12582912 3122408 1048576)) (stdout "") (stderr ""))

test/stream-sicp/merge-hamming: pass

(define (test/stream-sicp/merge-hamming _)
  (let* ((C (○ eval car))
         (L (λ (p q) `((* ,(C p) ,(C q)) ,(list (cadr p) (cadr q))))))
    (letdelay
      ((α (stream:cons
            '(1 i)
            ((stream:merge (λ (p q) (< (C p) (C q))))
             ((stream:zip-with L) α (stream:repeat '(2 a)))
             ((stream:zip-with L) α (stream:repeat '(3 b)))
             ((stream:zip-with L) α (stream:repeat '(5 c)))))))
      (⊦≡ '((1 i)
            ((* 1 2) (i a))
            ((* 1 3) (i b))
            ((* 2 2) ((i a) a))
            ((* 1 5) (i c))
            ((* 2 3) ((i a) b))
            ((* 3 2) ((i b) a))
            ((* 4 2) (((i a) a) a))
            ((* 3 3) ((i b) b))
            ((* 2 5) ((i a) c))
            ((* 5 2) ((i c) a))
            ((* 4 3) (((i a) a) b))
            ((* 6 2) (((i a) b) a))
            ((* 6 2) (((i b) a) a))
            ((* 3 5) ((i b) c))
            ((* 5 3) ((i c) b))
            ((* 8 2) ((((i a) a) a) a))
            ((* 6 3) (((i a) b) b))
            ((* 6 3) (((i b) a) b))
            ((* 9 2) (((i b) b) a))
            ((* 4 5) (((i a) a) c))
            ((* 10 2) (((i a) c) a))
            ((* 10 2) (((i c) a) a))
            ((* 8 3) ((((i a) a) a) b))
            ((* 12 2) ((((i a) a) b) a))
            ((* 12 2) ((((i a) b) a) a))
            ((* 12 2) ((((i b) a) a) a))
            ((* 5 5) ((i c) c))
            ((* 9 3) (((i b) b) b))
            ((* 6 5) (((i a) b) c))
            ((* 6 5) (((i b) a) c))
            ((* 10 3) (((i a) c) b))
            ((* 10 3) (((i c) a) b))
            ((* 15 2) (((i b) c) a))
            ((* 15 2) (((i c) b) a))
            ((* 16 2) (((((i a) a) a) a) a))
            ((* 12 3) ((((i a) a) b) b))
            ((* 12 3) ((((i a) b) a) b))
            ((* 12 3) ((((i b) a) a) b))
            ((* 18 2) ((((i a) b) b) a))
            ((* 18 2) ((((i b) a) b) a))
            ((* 18 2) ((((i b) b) a) a))
            ((* 8 5) ((((i a) a) a) c))
            ((* 20 2) ((((i a) a) c) a))
            ((* 20 2) ((((i a) c) a) a))
            ((* 20 2) ((((i c) a) a) a))
            ((* 9 5) (((i b) b) c))
            ((* 15 3) (((i b) c) b))
            ((* 15 3) (((i c) b) b))
            ((* 16 3) (((((i a) a) a) a) b)))
          ((list○take 50) α)))))
((eta 0.002) (memory #(12582912 3140480 1048576)) (stdout "") (stderr ""))

test/stream-sicp/enumerations: pass

(define (test/stream-sicp/enumerations _)
  (⊦≡ '(0 1 2 3 4 5 6 7 8 9)
      ((list○take 10) (stream:enumerate-upper numbers/nats/∞)))
  (⊦≡ '(0 1 2 3 4 5 6 7 8 9)
      ((list○take 10) (stream:enumerate-lower numbers/nats/∞)))
  (⊦≡ '((0 0) (0 1) (1 1) (0 2) (1 2) (0 3) (2 2) (0 4) (1 3) (0 5))
      ((list○take 10) (stream:enumerate-upper numbers/nats/∞ numbers/nats/∞)))
  (⊦≡ '((0 0 0)
        (0 0 1)
        (1 0 1)
        (0 1 1)
        (1 1 1)
        (0 0 2)
        (2 1 1)
        (0 1 2)
        (1 0 2)
        (0 0 3))
      ((list○take 10)
       (stream:enumerate-upper numbers/nats/∞ numbers/nats/∞ numbers/nats/∞)))
  (⊦≡ '((0 0 0 0)
        (0 0 0 1)
        (1 0 0 1)
        (0 1 0 1)
        (1 1 0 1)
        (0 0 1 1)
        (2 1 0 1)
        (0 1 1 1)
        (1 0 1 1)
        (0 0 0 2))
      ((list○take 10)
       (stream:enumerate-upper
         numbers/nats/∞
         numbers/nats/∞
         numbers/nats/∞
         numbers/nats/∞)))
  (⊦≡ '((0 0) (1 0) (1 1) (2 0) (2 1) (3 0) (2 2) (4 0) (3 1) (5 0))
      ((list○take 10) (stream:enumerate-lower numbers/nats/∞ numbers/nats/∞)))
  (⊦≡ '((0 0 0)
        (1 0 0)
        (1 1 0)
        (2 0 0)
        (2 1 0)
        (3 0 0)
        (2 1 1)
        (4 0 0)
        (3 1 0)
        (5 0 0))
      ((list○take 10)
       (stream:enumerate-lower numbers/nats/∞ numbers/nats/∞ numbers/nats/∞)))
  (⊦≡ '((0 0 0 0)
        (1 0 0 0)
        (1 1 0 0)
        (2 0 0 0)
        (2 1 0 0)
        (3 0 0 0)
        (2 1 1 0)
        (4 0 0 0)
        (3 1 0 0)
        (5 0 0 0))
      ((list○take 10)
       (stream:enumerate-lower
         numbers/nats/∞
         numbers/nats/∞
         numbers/nats/∞
         numbers/nats/∞)))
  (⊦≡ '((0 0) (0 1) (1 0) (1 1) (2 0) (0 2) (3 0) (1 2) (4 0) (0 3))
      ((list○take 10) (stream:enumerate-all numbers/nats/∞ numbers/nats/∞)))
  (⊦≡ 397
      ((compose
         length
         stream:->list
         (stream:take-while (λ (pair) ((compose not equal?) pair '(1 100)))))
       (stream:enumerate-upper numbers/nats/∞ numbers/nats/∞)))
  (⊦≡ 1559
      ((compose
         length
         stream:->list
         (stream:take-while (λ (pair) (not (equal? pair '(3 100))))))
       (stream:enumerate-upper numbers/nats/∞ numbers/nats/∞)))
  (let ((five (list->stream '(1 2 3 4 5))) (two (list->stream '(1 2))))
    (⊦≡ '((1 1) (1 2) (2 2)) (stream:->list (stream:enumerate-upper five two)))
    (⊦≡ '((1 1) (1 2) (2 2) (1 3) (2 3) (1 4) (2 4) (1 5) (2 5))
        (stream:->list (stream:enumerate-upper two five)))
    (⊦≡ '((1 1) (2 1) (2 2)) (stream:->list (stream:enumerate-lower two five)))
    (⊦≡ '((1 1) (2 1) (2 2) (3 1) (3 2) (4 1) (4 2) (5 1) (5 2))
        (stream:->list (stream:enumerate-lower five two)))
    (⊦≡ 10 (length (stream:->list (stream:enumerate-all five two))))
    (⊦≡ '((1 1) (1 2) (2 2))
        (stream:->list ((stream:enumerate-weighted +) five two)))
    (⊦≡ '(1 2) (stream:->list (stream:enumerate-upper two)))))
((eta 0.003) (memory #(12582912 3310776 1048576)) (stdout "") (stderr ""))

test/stream-sicp/map-pairs: pass

(define (test/stream-sicp/map-pairs _)
  (⊦≡ '(3 7)
      (stream:->list
        ((stream:map-consecutive-pairs +) (list->stream '(1 2 3 4)))))
  (⊦≡ '(3 7)
      (stream:->list
        ((stream:map-consecutive-pairs +) (list->stream '(1 2 3 4 5)))))
  (⊦≡ '(3 5 7)
      (stream:->list
        ((stream:map-overlapping-pairs +) (list->stream '(1 2 3 4)))))
  (⊦≡ '()
      (stream:->list ((stream:map-overlapping-pairs +) (list->stream '(1)))))
  (⊦≡ '(1 5 9 13 17)
      ((list○take 5) ((stream:map-consecutive-pairs +) numbers/nats)))
  (⊦≡ '(1 3 5 7 9)
      ((list○take 5) ((stream:map-overlapping-pairs +) numbers/nats))))
((eta 0.0) (memory #(12582912 3311440 1048576)) (stdout "") (stderr ""))

test/stream-sicp/weighted-enumerations: pass

(define (test/stream-sicp/weighted-enumerations _)
  (⊦≡ '((4 3 5)
        (3 4 5)
        (8 6 10)
        (6 8 10)
        (12 5 13)
        (12 9 15)
        (15 8 17)
        (5 12 13)
        (16 12 20)
        (9 12 15))
      ((list○take 10) (Pythagorean-triples 2)))
  (⊦≡ '((0 0) (0 1) (1 1) (0 2) (1 2) (0 3) (2 2) (1 3) (0 4) (2 3))
      ((list○take 10)
       ((stream:enumerate-weighted +) numbers/nats/∞ numbers/nats/∞)))
  (let* ((F (λ (x)
               (not (or ((divisable-by? 2) x)
                        ((divisable-by? 3) x)
                        ((divisable-by? 5) x)))))
         (O (λ (i j) (+ (* i 2) (* j 3) (* 5 i j))))
         (pairs ((stream:enumerate-weighted O)
                 ((stream:filter F) numbers/nats>0)
                 ((stream:filter F) numbers/nats>0))))
    (⊦≡ '((1 1)
          (1 7)
          (1 11)
          (1 13)
          (1 17)
          (1 19)
          (1 23)
          (1 29)
          (1 31)
          (7 7)
          (1 37)
          (1 41)
          (1 43)
          (1 47)
          (1 49)
          (1 53)
          (7 11)
          (1 59)
          (1 61)
          (7 13))
        ((list○take 20) pairs))
    (⊦≡ '(10
          58
          90
          106
          138
          154
          186
          234
          250
          280
          298
          330
          346
          378
          394
          426
          432
          474
          490
          508)
        ((list○take 20) ((stream:map (λ (p) (apply O p))) pairs)))))
((eta 0.028) (memory #(12582912 3192168 1048576)) (stdout "") (stderr ""))

test/stream-sicp/ramanujan-cubes: pass

(define (test/stream-sicp/ramanujan-cubes _)
  (let* ((W (λ (i j) (+ (expt i 3) (expt j 3))))
         (sums-of-cubes
           ((stream:enumerate-weighted W) numbers/nats>0 numbers/nats>0)))
    (letrec ((F (λ (s)
                   (let ((c (stream:car s)) (o (stream:cadr s)))
                     (delay-force
                       (cond ((equal? (apply W c) (apply W o))
                              (stream:cons
                                (list (apply W c) c o)
                                (F (stream:cdr s))))
                             (else (F (stream:cdr s)))))))))
      (⊦≡ '((1729 (9 10) (1 12))
            (4104 (9 15) (2 16))
            (13832 (18 20) (2 24))
            (20683 (19 24) (10 27))
            (32832 (18 30) (4 32))
            (39312 (15 33) (2 34))
            (40033 (16 33) (9 34))
            (46683 (27 30) (3 36))
            (64232 (26 36) (17 39))
            (65728 (31 33) (12 40)))
          ((list○take 10) (F sums-of-cubes))))))
((eta 0.011) (memory #(12582912 3289480 1048576)) (stdout "") (stderr ""))

test/stream-sicp/sums-of-three-squares: pass

(define (test/stream-sicp/sums-of-three-squares _)
  (let* ((W (λ (i j) (+ (expt i 2) (expt j 2))))
         (sums-of-squares
           ((stream:enumerate-weighted W) numbers/nats>0 numbers/nats>0)))
    (letrec ((F (λ (s)
                   (let ((c (stream:car s))
                         (o (stream:cadr s))
                         (p (stream:caddr s)))
                     (delay-force
                       (cond ((and (equal? (apply W c) (apply W o))
                                   (equal? (apply W o) (apply W p)))
                              (stream:cons
                                (list (apply W c) c o p)
                                (F (stream:cdr s))))
                             (else (F (stream:cdr s)))))))))
      (⊦≡ '((325 (10 15) (6 17) (1 18))
            (425 (13 16) (8 19) (5 20))
            (650 (17 19) (11 23) (5 25))
            (725 (14 23) (10 25) (7 26))
            (845 (19 22) (13 26) (2 29))
            (850 (15 25) (11 27) (3 29))
            (925 (21 22) (14 27) (5 30))
            (1025 (20 25) (8 31) (1 32))
            (1105 (23 24) (12 31) (9 32))
            (1105 (12 31) (9 32) (4 33)))
          ((list○take 10) (F sums-of-squares))))))
((eta 0.006) (memory #(12582912 3250648 1048576)) (stdout "") (stderr ""))

test/stream-sicp/interop-with-aux-streams: pass

(define (test/stream-sicp/interop-with-aux-streams _)
  (⊦≡ '(0 1 2 3 4) ((list○take 5) ℕ))
  (⊦≡ '(0 1 3 6 10) ((list○take 5) (series:× ℕ stream:1s)))
  (⊦≡ '(0 1 1 2 3) (§->list (take§ 5 numbers/fibs/∞)))
  (⊦≡ '(1 1 2 5 14) (§->list (take§ 5 taylor/catalan)))
  (⊦≡ '(0 1) ((list○take 3) (take§ 2 ℕ))))
((eta 0.0) (memory #(12582912 3254904 1048576)) (stdout "") (stderr ""))

(aux stream series): sequences and power series as streams

test/stream-series/fibonacci: pass

(define (test/stream-series/fibonacci _)
  (⊦≡ '(0 1 1 2 3 5 8 13 21 34) ((list○take 10) numbers/fibonacci))
  (⊦≡ '(0 1 2 4 7 12 20 33 54 88 143 232 376 609 986 1596 2583 4180 6764 10945)
      ((list○take 20) numbers/fibonacci-triangular))
  (⊦≡ ((list○take 10) ((stream:map sub1) numbers/fibonacci>0))
      ((list○take 10) (stream:cons 0 numbers/fibonacci-triangular))))
((eta 0.0) (memory #(12582912 3175352 1048576)) (stdout "") (stderr ""))

test/stream-series/primes: pass

(define (test/stream-series/primes _)
  (⊦≡ '(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)
      ((list○take 100) primes/eratosthenes))
  (⊦≡ '(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)
      ((list○take 100) primes/∞)))
((eta 0.003) (memory #(12582912 3262336 1048576)) (stdout "") (stderr ""))

test/stream-series/radix-expansion: pass

(define (test/stream-series/radix-expansion _)
  (⊦≡ '(1 4 2 8 5 7 1 4 2 8 5 7 1 4 2 8 5 7 1 4)
      ((list○take 20) (radix-expansion 1 7 10)))
  (⊦≡ '(18 5 7 1 4 2 8 5 7 1 4 2 8 5 7 1 4 2 8 5)
      ((list○take 20) (radix-expansion 13 7 10)))
  (⊦≡ '(3 7 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
      ((list○take 20) (radix-expansion 3 8 10))))
((eta 0.0) (memory #(12582912 3259688 1048576)) (stdout "") (stderr ""))

test/stream-series/recursive-definitions: pass

(define (test/stream-series/recursive-definitions _)
  (⊦≡ '(0 1 2 3 4 5 6 7 8 9) ((list○take 10) numbers/nats/∞))
  (⊦≡ '(0 1 1 2 3 5 8 13 21 34) ((list○take 10) numbers/fibs/∞))
  (⊦≡ '(2 1 3 4 7 11 18 29 47 76) ((list○take 10) numbers/lucas/∞))
  (⊦≡ '(1 2 4 8 16 32 64 128 256 512) ((list○take 10) numbers/powers-of-2))
  (⊦≡ '(1 2 4 8 16 32 64 128 256 512) ((list○take 10) numbers/powers-of-2/∞))
  (⊦≡ '(1 3 9 27 81 243 729 2187 6561 19683)
      ((list○take 10) numbers/powers-of-3))
  (⊦≡ '(1 3 9 27 81 243 729 2187 6561 19683)
      ((list○take 10) numbers/powers-of-3/∞))
  (⊦≡ '(1 1 2 6 24 120 720 5040 40320 362880)
      ((list○take 10) numbers/factorials/∞))
  (⊦≡ '(1 2 4 7 11 16 22 29 37 46)
      ((list○take 10) numbers/central-polygonal/∞)))
((eta 0.0) (memory #(12582912 3259000 1048576)) (stdout "") (stderr ""))

test/stream-series/factorization-and-prime?: pass

(define (test/stream-series/factorization-and-prime? _)
  (⊦≡ '(1 0 1 0 0 0 0 0 0 0) ((list○take 10) (factorization 10)))
  (⊦≡ '(0 0 0 0 0 0 1 0 0 0) ((list○take 10) (factorization 17)))
  (⊦≡ '(3 1 0 0 0 0 0 0 0 0) ((list○take 10) (factorization 24)))
  (⊦≡ #t ((○ not prime?) 55))
  (⊦≡ #t (prime? 17))
  (⊦≡ #t (prime? 17389))
  (⊦≡ #f (prime? 17391))
  (⊦≡ #f (prime? 1)))
((eta 0.073) (memory #(12582912 3396664 1048576)) (stdout "") (stderr ""))

test/stream-series/scans: pass

(define (test/stream-series/scans _)
  (⊦≡ '(0 1 3 6 10 15 21 28 36 45) ((list○take 10) numbers/triangular/+scan))
  (⊦≡ '(0 1 2 4 7 12 20 33 54 88) ((list○take 10) numbers/fibs/+scan))
  (⊦≡ ((list○take 10) numbers/fibs/+scan)
      ((list○take 10)
       ((stream:zip-with -) (stream:cddr numbers/fibs/∞) stream:1s)))
  (⊦≡ '(1 1 2 6 30 240 3120 65520 2227680 122522400)
      ((list○take 10) numbers/fibs/∙scan))
  (⊦≡ '(100 99 97 94)
      (stream:->list ((stream:scan -) (list->stream '(100 1 2 3)))))
  (⊦≡ '(a (a b) ((a b) c))
      (stream:->list ((stream:scan list) (list->stream '(a b c)))))
  (⊦≡ '() (stream:->list ((stream:scan +) stream:empty))))
((eta 0.0) (memory #(12582912 3400520 1048576)) (stdout "") (stderr ""))

test/stream-series/series-basics: pass

(define (test/stream-series/series-basics _)
  (⊦≡ '(1 1/2 3/8 5/16 35/128 63/256 231/1024 429/2048 6435/32768 12155/65536)
      ((list○take 10) (series:√/∞ stream:1s)))
  (⊦≡ ((list○take 10) stream:1s)
      ((list○take 10) ((compose (series:expt 2) series:√/∞) stream:1s)))
  (⊦≡ '(2 1/4 -1/64 1/512 -5/16384)
      ((list○take 5) (series:√/∞ (list->poly '(4 1)))))
  (⊦≡ '(4 1 0 0 0)
      ((list○take 5)
       ((compose (series:expt 2) series:√/∞) (list->poly '(4 1)))))
  (⊦≡ '(0 1 0 0 0) ((list○take 5) (series:√/∞ (list->poly '(0 0 1)))))
  (⊨ (condition-case
       (begin ((list○take 5) (series:√/∞ (list->poly '(0 1)))) #f)
       ((exn) #t)))
  (⊦≡ '(1 2 3 4 5 6 7 8 9 10) ((list○take 10) (series:× stream:1s stream:1s)))
  (⊦≡ '(0 1 1 1) (stream:->list (series:∫ (list->stream '(1 2 3)))))
  (⊦≡ '(2 6) (stream:->list (series:∂ (list->stream '(1 2 3)))))
  (⊦≡ '() (stream:->list (series:∂ (list->stream '(1)))))
  (⊦≡ '(0 1 3 6 10 15 21 28 36 45)
      ((list○take 10) (series:× numbers/nats/∞ stream:1s))))
((eta 0.001) (memory #(12582912 3412344 1048576)) (stdout "") (stderr ""))

test/stream-series/series-exp-and-composition: pass

(define (test/stream-series/series-exp-and-composition _)
  (⊨ (condition-case
       (begin ((list○take 10) (series:exp stream:1)) #f)
       ((exn) #t)))
  (⊦≡ '(1 0 0 0 0 0 0 0 0 0) ((list○take 10) (series:exp series:0)))
  (⊦≡ '(1 0 0 0 0 0 0 0 0 0)
      ((list○take 10) (series:○ taylor/exponential series:0)))
  (⊦≡ '(1 1 1/2 1/6 1/24 1/120 1/720 1/5040 1/40320 1/362880)
      ((list○take 10) taylor/exponential))
  (⊦≡ '(1 1 1/2 1/6 1/24 1/120 1/720 1/5040 1/40320 1/362880)
      ((list○take 10) (series:exp `(0 ,@stream:1))))
  (⊦≡ '(1 1 1/2 1/6 1/24 1/120 1/720 1/5040 1/40320 1/362880)
      ((list○take 10) (series:exp (list->poly '(0 1)))))
  (⊦≡ '(1 1 1/2 1/6 1/24 1/120 1/720 1/5040 1/40320 1/362880)
      ((list○take 10) (series:○ taylor/exponential (list->poly '(0 1)))))
  (⊦≡ '(1 1 1/2 1/6 1/24 1/120 1/720 1/5040 1/40320 1/362880)
      ((list○take 10) (series:exp (list->poly '(0 1)))))
  (⊦≡ '(1
        1
        3/2
        13/6
        73/24
        167/40
        4051/720
        37633/5040
        43817/4480
        4596553/362880)
      ((list○take 10) (series:exp `(0 ,@stream:1s))))
  (⊦≡ '(1
        1
        3/2
        13/6
        73/24
        167/40
        4051/720
        37633/5040
        43817/4480
        4596553/362880)
      ((list○take 10) (series:○ taylor/exponential `(0 ,@stream:1s)))))
((eta 0.001) (memory #(12582912 3427880 1048576)) (stdout "") (stderr ""))

test/stream-series/trigonometric: pass

(define (test/stream-series/trigonometric _)
  (⊦≡ '(1 0 -1/2 0 1/24 0 -1/720 0 1/40320 0) ((list○take 10) taylor/cosine))
  (⊦≡ '(0 1 0 -1/6 0 1/120 0 -1/5040 0 1/362880) ((list○take 10) taylor/sine))
  (let ((sine2+cosine2
          (series:+
            (series:× taylor/sine taylor/sine)
            (series:× taylor/cosine taylor/cosine)))
        (tangent-series (series:/ taylor/sine taylor/cosine))
        (arctan-series (series:∫ (series:/ stream:1 (list->poly '(1 0 1))))))
    (⊦≡ '(1 0 0 0 0 0 0 0 0 0) ((list○take 10) sine2+cosine2))
    (⊦≡ '(0 1 0 1/3 0 2/15 0 17/315 0 62/2835) ((list○take 10) tangent-series))
    (⊦≡ '(0 1 0 -1/3 0 1/5 0 -1/7 0 1/9) ((list○take 10) arctan-series))
    (⊦≡ ((list○take 10) series:0)
        ((list○take 10)
         ((stream:zip-with -)
          (series:/ taylor/sine taylor/cosine)
          (series:◇ arctan-series))))))
((eta 0.0) (memory #(12582912 3457080 1048576)) (stdout "") (stderr ""))

test/stream-series/series-inverse: pass

(define (test/stream-series/series-inverse _)
  (⊦≡ '(1 -1 0 0 0 0 0 0 0 0) ((list○take 10) (series:⁻¹ stream:1s)))
  (⊦≡ '(1 -2 1 0 0 0 0 0 0 0) ((list○take 10) (series:⁻¹ numbers/nats>0)))
  (⊦≡ '(1 0 0 0 0 0 0 0 0 0)
      ((list○take 10) (series:× numbers/nats>0 (series:⁻¹ numbers/nats>0))))
  (⊦≡ '(1 -1 -1 0 0 0 0 0 0 0)
      ((list○take 10) (series:⁻¹ (stream:cdr numbers/fibs/∞))))
  (⊦≡ '(1 0 0 0 0 0 0 0 0 0)
      ((list○take 10)
       (series:× numbers/fibs>0/∞ (series:⁻¹ numbers/fibs>0/∞))))
  (let ((non-unary-series (stream:cons 4 numbers/nats>0)))
    (⊦≡ '(1/4
          -1/16
          -7/64
          -33/256
          -119/1024
          -305/4096
          -231/16384
          3263/65536
          26537/262144
          133551/1048576)
        ((list○take 10) (series:⁻¹ non-unary-series)))
    (⊦≡ '(1 0 0 0 0 0 0 0 0 0)
        ((list○take 10)
         (series:× non-unary-series (series:⁻¹ non-unary-series))))))
((eta 0.001) (memory #(12582912 3428768 1048576)) (stdout "") (stderr ""))

test/stream-series/series-division-and-reversion: pass

(define (test/stream-series/series-division-and-reversion _)
  (⊦≡ '(1 0 -6 0 12 0 -8 0 0 0)
      ((list○take 10) ((series:expt 3) (list->poly '(1 0 -2)))))
  (⊦≡ '(1 1 1 1 1 1 1 1 1 1)
      ((list○take 10) (series:/ stream:1 (list->poly '(1 -1)))))
  (⊦≡ '(0 1 1 2 3 5 8 13 21 34)
      ((list○take 10) (series:/ (formalvar-series 1) (list->poly '(1 -1 -1)))))
  (⊦≡ '(1 2 3 4 5 6 7 8 9 10)
      ((list○take 10)
       (series:/ stream:1 ((series:expt 2) (list->poly '(1 -1))))))
  (⊦≡ '(0 1 -1 1 -1 1 -1 1 -1 1)
      ((list○take 10) (series:◇ (stream:cons 0 stream:1s))))
  (⊦≡ '(0 1 -1 1 -1 1 -1 1 -1 1)
      ((list○take 10) (series:/ (formalvar-series 1) (list->poly '(1 1))))))
((eta 0.0) (memory #(12582912 3433800 1048576)) (stdout "") (stderr ""))

test/stream-series/riordan-and-multivariate: pass

(define (test/stream-series/riordan-and-multivariate _)
  (⊦≡ '((1)
        (1 1)
        (1 2 1)
        (1 3 3 1)
        (1 4 6 4 1)
        (1 5 10 10 5 1)
        (1 6 15 20 15 6 1)
        (1 7 21 35 35 21 7 1)
        (1 8 28 56 70 56 28 8 1)
        (1 9 36 84 126 126 84 36 9 1))
      ((list○take 10) (riordan-array stream:1s stream:1s)))
  (⊦≡ ((list○take 10) (series:/ (formalvar-series 1) `(1 1 unquote series:0)))
      ((list○take 10) (series:◇ (stream:cons 0 stream:1s))))
  (let ((rows ((list○take 10)
               (series:○
                 (series:/ stream:1 (list->poly '(1 -1)))
                 (list->poly `(,(list->poly '()) ,(list->poly '(1 1))))))))
    (⊦≡ '((1)
          (1 1)
          (1 2 1)
          (1 3 3 1)
          (1 4 6 4 1)
          (1 5 10 10 5 1)
          (1 6 15 20 15 6 1)
          (1 7 21 35 35 21 7 1)
          (1 8 28 56 70 56 28 8 1)
          (1 9 36 84 126 126 84 36 9 1))
        ((map/with-index list○take 1) rows)))
  (⊦≡ '((1 0 0 0 0 0 0 0 0 0)
        (1 1 1 1 1 1 1 1 1 1)
        (1 2 3 4 5 6 7 8 9 10)
        (1 3 6 10 15 21 28 36 45 55)
        (1 4 10 20 35 56 84 120 165 220)
        (1 5 15 35 70 126 210 330 495 715)
        (1 6 21 56 126 252 462 792 1287 2002)
        (1 7 28 84 210 462 924 1716 3003 5005)
        (1 8 36 120 330 792 1716 3432 6435 11440)
        (1 9 45 165 495 1287 3003 6435 12870 24310))
      (let ((rows ((list○take 10)
                   (series:○
                     (series:/ stream:1 (list->poly '(1 -1)))
                     (list->poly `(,(list->poly '()) ,stream:1s))))))
        (map (list○take 10) rows)))
  (⊦≡ '((1 1 1 1 1 1 1 1 1 1)
        (0 1 2 3 4 5 6 7 8 9)
        (0 0 1 3 6 10 15 21 28 36)
        (0 0 0 1 4 10 20 35 56 84)
        (0 0 0 0 1 5 15 35 70 126)
        (0 0 0 0 0 1 6 21 56 126)
        (0 0 0 0 0 0 1 7 28 84)
        (0 0 0 0 0 0 0 1 8 36)
        (0 0 0 0 0 0 0 0 1 9)
        (0 0 0 0 0 0 0 0 0 1))
      (let ((rows ((list○take 10)
                   ((stream:zip-with series:×)
                    stream:1s
                    (series:○
                      (series:/ stream:1 (list->poly '(1 -1)))
                      (list->poly
                        `(,(list->poly '()) ,(stream:cons 0 stream:1s))))))))
        (map (list○take 10) rows)))
  (⊦≡ '((1 0 0 0 0 0 0 0 0 0)
        (0 1 1 1 1 1 1 1 1 1)
        (0 0 1 2 3 4 5 6 7 8)
        (0 0 0 1 3 6 10 15 21 28)
        (0 0 0 0 1 4 10 20 35 56)
        (0 0 0 0 0 1 5 15 35 70)
        (0 0 0 0 0 0 1 6 21 56)
        (0 0 0 0 0 0 0 1 7 28)
        (0 0 0 0 0 0 0 0 1 8)
        (0 0 0 0 0 0 0 0 0 1))
      (let ((rows ((list○take 10)
                   (series:○
                     (series:/ stream:1 (list->poly '(1 -1)))
                     (list->poly
                       `(,(list->poly '()) ,(stream:cons 0 stream:1s)))))))
        (map (list○take 10) rows)))
  (⊦≡ '((1 0 0 0 0 0 0 0 0 0)
        (0 1 1 1 1 1 1 1 1 1)
        (0 0 2 3 4 5 6 7 8 9)
        (0 0 0 3 7 12 18 25 33 42)
        (0 0 0 0 5 15 31 54 85 125)
        (0 0 0 0 0 8 30 73 145 255)
        (0 0 0 0 0 0 13 58 162 361)
        (0 0 0 0 0 0 0 21 109 344)
        (0 0 0 0 0 0 0 0 34 201)
        (0 0 0 0 0 0 0 0 0 55))
      (let ((rows ((list○take 10)
                   (series:○
                     (series:/ stream:1 (list->poly '(1 -1)))
                     (list->poly
                       `(,(list->poly '())
                         ,(stream:cons 0 stream:1s)
                         ,(stream:cons 0 (stream:cons 0 stream:1s))))))))
        (map (list○take 10) rows)))
  (⊦≡ '((1)
        (1 1)
        (1 3 1)
        (1 6 5 1)
        (1 10 15 7 1)
        (1 15 35 28 9 1)
        (1 21 70 84 45 11 1)
        (1 28 126 210 165 66 13 1)
        (1 36 210 462 495 286 91 15 1)
        (1 45 330 924 1287 1001 455 120 17 1))
      ((list○take 10) (riordan-array stream:1s (series:from 1)))))
((eta 0.081) (memory #(12582912 3442696 1048576)) (stdout "") (stderr ""))

test/stream-series/bivariate-products: pass

(define (test/stream-series/bivariate-products _)
  (let ((rows (λ (n m s) (map (list○take m) ((list○take n) s))))
        (x+y (list->poly (list (list->poly '(0 1)) 1)))
        (|1+x| (list->poly (list (series:const 1) (series:const 1)))))
    (⊦≡ '((0 0 1) (0 2 0) (1 0 0)) (rows 3 3 (series:×* x+y x+y)))
    (⊦≡ '((1 0 0 0) (2 0 0 0) (1 0 0 0)) (rows 3 4 (series:×* |1+x| |1+x|)))
    (⊦≡ '((0 0 0) (0 0 0) (1 0 0) (0 2 0) (0 0 1))
        (rows 5
              3
              (series:○
                (list->poly '(0 0 1))
                (list->poly (list (list->poly '()) 1 (list->poly '(0 1)))))))
    (let ((zeros (stream:repeat 0))
          (geometric (series:/ stream:1 (list->poly '(1 -1))))
          (|1+y| (list->poly '(1 1)))
          (y (list->poly '(0 1))))
      (⊦≡ '((1 0 0) (1 1 0) (1 2 1))
          (rows 3 3 (series:○ geometric (list->poly (list zeros |1+y|)))))
      ((stream:ref 3) zeros)
      ((stream:ref 3) series:0)
      (⊦≡ '((1 0 0) (1 1 0) (1 2 1))
          (rows 3 3 (series:○ geometric (list->poly (list zeros |1+y|)))))
      (⊦≡ '((1 1 1 1) (1 2 3 4) (1 3 6 10) (1 4 10 20))
          (rows 4 4 (series:○ geometric x+y)))
      (⊦≡ '((1 1 1 1) (0 1 2 3) (0 0 1 3) (0 0 0 1))
          (rows 4 4 (series:○ geometric (list->poly (list y y)))))
      (⊦≡ '((0 0 1) (0 2 0) (1 0 0))
          (rows 3 3 (series:○ (list->poly '(0 0 1)) x+y)))
      (⊦≡ '((0 0 1) (0 2 0) (1 0 0))
          (rows 3 3 (series:○ (list->stream '(0 0 1)) x+y)))
      (⊦≡ '((1 1 1/2) (1 1 1/2) (1/2 1/2 1/4))
          (rows 3 3 (series:○ (series:exp y) x+y)))
      (⊨ (condition-case
           (begin
             ((list○take 3) (series:○ geometric (list->poly (list 1 |1+y|))))
             #f)
           ((exn) #t)))
      (⊨ (condition-case
           (begin
             ((list○take 3)
              (series:○ geometric (list->poly (list (series:const 5) |1+y|))))
             #f)
           ((exn) #t))))))
((eta 0.001) (memory #(12582912 3449040 1048576)) (stdout "") (stderr ""))

test/stream-series/catalan: pass

(define (test/stream-series/catalan _)
  (⊦≡ '(1 1 2 5 14 42 132 429 1430 4862) ((list○take 10) taylor/catalan))
  (⊦≡ '(0 1 1 2 5 14 42 132 429 1430)
      ((list○take 10)
       (series:/
         (series:- stream:1 (series:√/∞ (list->poly '(1 -4))))
         (list->poly '(2)))))
  (letdelay
    ((tree (stream:cons 0 forest))
     (lst (stream:cons 1 lst))
     (forest (series:○ lst tree)))
    (⊦≡ '(0 1 1 2 5 14 42 132 429 1430) ((list○take 10) tree)))
  (⊦≡ '((1)
        (1 1)
        (2 2 1)
        (5 5 3 1)
        (14 14 9 4 1)
        (42 42 28 14 5 1)
        (132 132 90 48 20 6 1)
        (429 429 297 165 75 27 7 1)
        (1430 1430 1001 572 275 110 35 8 1)
        (4862 4862 3432 2002 1001 429 154 44 9 1))
      ((list○take 10) (riordan-array taylor/catalan taylor/catalan))))
((eta 0.001) (memory #(12582912 3463808 1048576)) (stdout "") (stderr ""))

test/stream-series/riordan-fibonacci-factorials: pass

(define (test/stream-series/riordan-fibonacci-factorials _)
  (⊦≡ '(1 1 2 3 5 8 13 21 34 55) ((list○take 10) taylor/fibonacci))
  (⊦≡ '((1)
        (1 1)
        (2 2 1)
        (3 5 3 1)
        (5 12 9 4 1)
        (8 31 26 14 5 1)
        (13 85 77 46 20 6 1)
        (21 248 235 150 73 27 7 1)
        (34 762 741 493 258 108 35 8 1)
        (55 2440 2406 1644 903 410 152 44 9 1))
      ((list○take 10) (riordan-array taylor/fibonacci taylor/catalan)))
  (⊦≡ '((1)
        (1 1)
        (2 2 1)
        (3 5 3 1)
        (5 10 9 4 1)
        (8 20 22 14 5 1)
        (13 38 51 40 20 6 1)
        (21 71 111 105 65 27 7 1)
        (34 130 233 256 190 98 35 8 1)
        (55 235 474 594 511 315 140 44 9 1))
      ((list○take 10) (riordan-array taylor/fibonacci taylor/fibonacci)))
  (⊦≡ '((1)
        (1 1)
        (2 2 1)
        (3 4 3 1)
        (5 7 7 4 1)
        (8 12 14 11 5 1)
        (13 20 26 25 16 6 1)
        (21 33 46 51 41 22 7 1)
        (34 54 79 97 92 63 29 8 1)
        (55 88 133 176 189 155 92 37 9 1))
      ((list○take 10) (riordan-array taylor/fibonacci stream:1s)))
  (⊦≡ '((1)
        (1 1)
        (2 2 1)
        (6 5 3 1)
        (24 15 9 4 1)
        (120 53 29 14 5 1)
        (720 222 102 49 20 6 1)
        (5040 1120 400 178 76 27 7 1)
        (40320 6849 1809 689 289 111 35 8 1)
        (362880 50111 9791 2942 1133 444 155 44 9 1))
      ((list○take 10) (riordan-array numbers/factorials/∞ taylor/catalan)))
  (⊦≡ '((1)
        (1 1)
        (2 2 1)
        (6 5 3 1)
        (24 16 9 4 1)
        (120 64 31 14 5 1)
        (720 312 126 52 20 6 1)
        (5040 1812 606 217 80 27 7 1)
        (40320 12288 3428 1040 345 116 35 8 1)
        (362880 95616 22572 5768 1661 519 161 44 9 1))
      ((list○take 10)
       (riordan-array numbers/factorials/∞ numbers/factorials/∞))))
((eta 0.002) (memory #(12582912 3456336 1048576)) (stdout "") (stderr ""))

test/stream-series/sqrt-pi-euler-tableau-log2: pass

(define (test/stream-series/sqrt-pi-euler-tableau-log2 _)
  (⊦≡ '(1 3/2 17/12 577/408 665857/470832) ((list○take 5) (series:√ 2)))
  (⊦≡ '(4
        8/3
        52/15
        304/105
        1052/315
        10312/3465
        147916/45045
        135904/45045
        2490548/765765
        44257352/14549535)
      ((list○take 10) taylor/π))
  (⊦≡ '(19/6
        47/15
        1321/420
        989/315
        21779/6930
        141481/45045
        1132277/360360
        801821/255255
        91424611/29099070
        45706007/14549535)
      ((list○take 10) (series:Euler-transform taylor/π)))
  (⊦≡ '(4
        19/6
        597/190
        73480501/23389520
        908158408158535624217/289075793976001466280
        6122842329181964122242157261623055408836895066390212805633550889340420878203921614979/1948961244684053510230839929806362227580597549551747444462336644887607671758516827680)
      ((list○take 6) ((stream:tableau series:Euler-transform) taylor/π)))
  (⊦≡ '(1 1/2 5/6 7/12 47/60 37/60 319/420 533/840 1879/2520 1627/2520)
      ((list○take 10) series:log₂))
  (⊨ (< (abs (- ((stream:ref 2000) taylor/π) (* 4 (atan 1)))) 1/1000))
  (⊨ (< (abs (- ((stream:ref 2000) series:log₂) (log 2))) 1/1000))
  (⊦≡ '(7/10
        29/42
        25/36
        457/660
        541/780
        97/140
        9901/14280
        33181/47880
        1747/2520
        441871/637560)
      ((list○take 10) (series:Euler-transform series:log₂)))
  (⊦≡ '(1
        7/10
        165/238
        380522285/548976276
        755849325680052062216639661/1090460049411856348776491380
        318738655178511632543822227346530350595387994474669640697143248267438214457834012964733985868157066661175569469393/459842677096914359400941379802880332404679211833600390612039625007123278498884893986945137648853585966630779010940)
      ((list○take 6) ((stream:tableau series:Euler-transform) series:log₂))))
((eta 0.011) (memory #(12582912 6250840 1048576)) (stdout "") (stderr ""))

test/stream-series/integrators-and-ode: pass

(define (test/stream-series/integrators-and-ode _)
  (let ((expected '(0 1/2 3/2 3 5 15/2 21/2 14 18 45/2)))
    (⊦≡ expected ((list○take 10) ((series:integrator 0 1/2) numbers/nats>0)))
    (⊦≡ expected
        ((list○take 10) ((series:integrator/∞ 0 1/2) numbers/nats>0))))
  (let ((expected
          2716923932235892457383088121947577188964315018836572803722354774868894945523768158997885697298661429053421034015406256924859461187617653889457753593083386399572063538500432650176144488046171044844121805479607648086607018742077798375087855857012278053105042704758822511824867218226931719410407150364389665913091822576819072281835735365786202176167228686198158460724641052407506305826211156964723064441295969498221919251479211700941935114755531972677360157561485144237786816579422141378066423317811515462669946309306263409027388915931082226854264858661420878279983534424128672461206356847463821364630504359665171573635397346037274752410368174877433941234543153511100471651472869116068528478976916600585383497180172395573924789047989563714318957536493108041591460911612078698461739084741934442448701416575483263891529095158013233115648534154086009312190489168546024398834243847135102411661996020129557921444666343641039137906807591342742464200991933722791531063202677650581946360422027765645970182463780273161113009717582155489902677095053354207944772439271656447869921825959042801322775729022491402012084605367784456090892987682547811360481731795980637847551788259384243997341190753089343387201753821360405430310320564488741142120089460368986590136324737459372963666586532443570474179352656517635333744783401695951969936296323256525034685525470426185224036844803487442831639483152362831735350269624668701702424450940840884555271325190876102665277858154695092765613639718577127438538649414492678358762110235621776218781360881010654696273264706319088453035858355052988808507775439561385232652305316287705653436727647681405618323757201022946801118770148072424021385261829594248369890171583993147934044232792517118743393217276416179842097554494269012251329134783596037733973478306188255291484352384699871420472711423079586319041837563678498472779422282261024744394844558738378027105699691260086532632930941478779680554645850778168703661423819000515895232903243738763481571999080702098369316199601942246247887808385073821861517636839926907458184604648942036355256683219218129910422822177336785268627274482037476294341444562207197209503659518266210432791078248321015453218019586608696207295299183111963158564162419152742807437346241667671688466998244424726765837682151606230638111654756595917019206453978024157097042546937345673337179165242325399648121877178987723999503839197328183925340949191821443698275476295245249466361817367207248089144718808572152781037112209285944844021186534832159964297181970584453756163204297111185823467744743465840230098261424789313315093951766314459027947176701489215746884363426961577348384651887153140609616362927338107686794499974902581579897076172716541504294334300741444106749994715713419630688719451362658288812132056854807330827050505064714442618243101018812153563795539024370219967801515099970721926240625418512417940854760415566229746248973756297569452302821563467574313259066016089521122779204844875998864114930516063910324359331903843040069467324167490917499501000001/1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000))
    (⊦≡ expected
        ((stream:ref 1000)
         ((series:ode-solver-1st (series:integrator/∞ 1 1/1000)) (λ (y) y))))))
((eta 0.255) (memory #(12582912 6597952 1048576)) (stdout "") (stderr ""))
Categories: scheme 

See also

The (aux anthropic) module The Anthropic Messages API, offline The (aux cml) module Events, threads, synchronous variables, the library and I/O The (aux hakaru10) modules Random sources, distributions, the language, exact inference and examples The (aux kanren) modules Arithmetic, dates, presentation of answers and a union-find miniKanren The (aux games dice-of-doom) module Dice of Doom The (aux machine) modules Environments, the SC machine and the SECD machine The (aux schemer seasoned) module The Seasoned Schemer The (aux continuation) modules Classic operators, escapers, amb and Collatz sequences The (aux category) modules Monads: list, maybe, probability, ziplist, difference lists and state The (aux timsort) module Sorting and the trace buffer The (aux fds) modules Functional queues and union-find The (aux sxml) module Rendering SXML to HTML The (aux variable) module Logic variables introduced by fresh The (aux tabling) module Memoization and tabled definitions The (aux commons) module Learning tests for CHICKEN Scheme Promises delay and make-promise The Ackermann function On unary numbers, as lists Concurrent ML for CHICKEN Scheme Porting SML/NJ CML as the (aux cml) library CHICKEN Scheme Versions and implementation notes The SBRAL data structure Skew Binary Random-Access Lists Pattern matching Scheme macrology: a generalized pattern matcher The (aux hansei) modules Inference, random sources, lazy lists, logic programming and example models The (aux nondeterministic) module Learning tests for Scheme The (aux unittest) module Bootstrapping a unittest framework Scheme lang: Chez, 48 and Chicken Some docs, refs and containers, respectively. The Reasoned Schemer miniKanren, microKanren and some implementations Aggregation predicates for µkanren Groups, window functions, sets and enumerations miniKanren, live and untagged Quine generation via relational interpreters Pure, declarative, and constructive arithmetic relations A declarative pearl Final shift for call/cc Direct implementation of shift and reset Call with Current Continuation Patterns Cogen in six lines The Seasoned Schemer The Little Schemer Adding generic functions to Scheme Handling control