Changeset 27200 in project


Ignore:
Timestamp:
08/05/12 13:56:40 (9 years ago)
Author:
juergen
Message:

dependency on clojurian removed

Location:
release/4/lazy-lists
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/4/lazy-lists/tags/0.2/lazy-lists.meta

    r27153 r27200  
    33((synopsis "implementation of lazy lists")
    44 (category data)
    5  (depends contracts records)
     5 (depends contracts)
    66 (license "BSD")
    7  (doc-from-wiki #t)
    8  (author "Juergen Lorenz")
    9  (files "lazy-lists.setup" "lazy-lists.release-info" "lazy-lists.meta" "lazy-lists.scm" "tests/run.scm"))
     7 (author "Juergen Lorenz"))
  • release/4/lazy-lists/tags/0.2/lazy-lists.scm

    r27153 r27200  
    523523) ; module %lazy-lists
    524524
    525 ;;(define (Take-with ok? seq)
    526 ;;  (let loop ((n 1) (seq seq))
    527 ;;    (print n);;;
    528 ;;    (if (or (Null? seq) (ok? (First seq)))
    529 ;;      Nil
    530 ;;      (Lazy n
    531 ;;        (cons (First seq) (loop (+ n 1) (Rest seq)))))))
    532 ;(define (First-five) (List 0 1 2 3 4))
    533 ;(define (Index ok? seq)
    534 ;  (let loop ((n 0) (seq seq))
    535 ;    (cond
    536 ;      ((Null? seq) #f)
    537 ;      ((ok? (First seq)) n)
    538 ;      (else (loop (+ n 1) (Rest seq))))))
    539 ;;(receive (head tail) (Split-at (Index (cut = <> 3) (List 0 1 2 3 4))
    540 ;;                               (List 0 1 2 3 4))
    541 ;;  (print (List->list head) " " (List->list tail)))
    542 
    543525(module lazy-lists
    544526  (Lazy make-lazy Car Cdr Nil Cons
     
    564546
    565547;; initialize documentation
    566 (doclist '())
     548(doclist '((Nil  "empty lazy list")))
    567549
    568550(define-syntax-with-contract Lazy
     
    603585  (%List xpr))
    604586
    605 (define Nil %Nil)
     587(define Nil
     588  %Nil)
    606589
    607590(define-with-contract (Interval from upto)
  • release/4/lazy-lists/tags/0.2/lazy-lists.setup

    r27153 r27200  
    22
    33(compile -O2 -s -d1 lazy-lists.scm -J)
    4 (compile -O2 -d0 -s lazy-lists.import.scm)
    5 (compile -O2 -d0 -s %lazy-lists.import.scm)
     4(compile -O3 -d0 -s lazy-lists.import.scm)
     5(compile -O3 -d0 -s %lazy-lists.import.scm)
    66
    77(install-extension
    88 'lazy-lists
    99 '("lazy-lists.so" "lazy-lists.import.so" "%lazy-lists.import.so")
    10  '((version "0.1")))
     10 '((version "0.2")))
  • release/4/lazy-lists/tags/0.2/tests/run.scm

    r27153 r27200  
    1 (require-library lazy-lists clojurian-syntax)
    2 (import lazy-lists clojurian-syntax)
     1(require-library lazy-lists)
     2(import lazy-lists)
    33
    44;;; (run xpr0 xpr1 ...)
     
    4848  (= (Length (First-five)) 5)
    4949  (= (Length (Rest (First-five))) 4)
    50   (->> (Cardinals) (Rest) (Length) (eq? #f))
    51   (->> (Cardinals) (Take 5) (Length) (= 5))
    52   (->> (Cardinals) (Length) (eq? #f))
    53   (->> (Cardinals) (Drop 5) (Length) (eq? #f))
    54   (->> (Cardinals) (Drop 5) (First) (= 5))
    55   (->> (First-five) (List->list) (equal? '(0 1 2 3 4)))
    56   (->> (Cardinals) (Take 5) (List->list) (equal? '(0 1 2 3 4)))
    57   (->> (Interval 2 10) (Length) (= (- 10 2)))
    58   (->> (Interval 2 10) (List->list) (equal? '(2 3 4 5 6 7 8 9)))
    59   (->> (Interval 10 2) (List->list) (equal? '(10 9 8 7 6 5 4 3)))
     50  (eq? (Length (Rest (Cardinals))) #f)
     51  (= (Length (Take 5 (Cardinals))) 5)
     52  (eq? (Length (Cardinals)) #f)
     53  (eq? (Length (Drop 5 (Cardinals))) #f)
     54  (= (First (Drop 5 (Cardinals))) 5)
     55  (equal? (List->list (First-five)) '(0 1 2 3 4))
     56  (equal? (List->list (Take 5 (Cardinals))) '(0 1 2 3 4))
     57  (= (Length (Interval 2 10)) (- 10 2))
     58  (equal? (List->list (Interval 2 10)) '(2 3 4 5 6 7 8 9))
     59  (equal? (List->list (Interval 10 2)) '(10 9 8 7 6 5 4 3))
    6060  (equal?
    6161    (receive (head index tail) (Split-with (cut = <> 3) (First-five))
     
    6666      (append (List->list tail) (List->list head)))
    6767    '(5 6 7 8 9 0 1 2 3 4))
    68   (->> (First-five) (Index (cut = <> 2)) (= 2))
    69   (->> (First-five) (Index (cut = <> 20)) (= 5))
    70   (->> (Cardinals) (Take 10) (Take-upto (cut = <> 5)) (List->list)
    71        (equal? '(0 1 2 3 4)))
    72   (->> (Cardinals) (Take 10) (Take-upto (cut = <> 5)) (Length) (= 5))
    73   (->> (Cardinals) (Take 10) (Drop-upto (cut = <> 5)) (Length) (= 5))
    74   (->> (Cardinals) (Take 10) (Drop-upto (cut = <> 5)) (First) (= 5))
    75   (->> (First-five) (Drop-upto (cut = <> 2)) (Length) (= 3))
    76   (->> (First-five) (Drop-upto (cut = <> 2)) (First) (= 2))
    77   (->> (First-five) (Memp odd?) (List->list) (equal? '(1 2 3 4)))
    78   (->> (Cardinals) (Take 10) (Memv 5) (List->list) (equal? '(5 6 7 8 9)))
    79   (->> (Cardinals) (Map (lambda (x) (list x x))) (Take 10) (Assv 5)
    80        (equal? '(5 5)))
    81   (->> (First-five) (Map (lambda (x) (list x x))) (Assv 10)
    82        (eq? #f))
    83   (->> (Cardinals) (Equal? (Cardinals)) (eq? #f))
    84   (->> (Cardinals) (Equal? (First-five)) (eq? #f))
    85   (->> (First-five) (Equal? (First-five)) (eq? #t))
    86   (->> (Cardinals) (Take 10) (Length) (= 10))
    87   (->> (Cardinals) (Drop 1) (Filter odd?) (Take 5) (List->list)
    88        (equal? '(1 3 5 7 9)))
    89   (->> (Cardinals) (Length) (eq? #f))
    90   (->> (First-five) (Map add1) (List->list) (equal? '(1 2 3 4 5)))
    91   (->> (Map + (First-five) (Take 5 (Cardinals))) (List->list)
    92        (equal? '(0 2 4 6 8)))
    93   (->> (Map + (Cardinals) (Cardinals)) (Length) (eq? #f))
    94   (->> (Filter odd? (First-five)) (Length) (= 2))
    95   (->> (Filter odd? (First-five)) (List->list) (equal? '(1 3)))
    96   (->> (Filter odd? (Cardinals)) (Length) (eq? #f))
    97   (->> (Zip (Cardinals) (Cardinals)) (Sieve =) (Ref 20) (= 20))
    98   (->> (Zip (First-five) (First-five)) (Sieve =) (List->list)
    99        (equal? '(0 1 2 3 4)))
    100   (->> (Ref 25 (Cardinals)) (= 25))
    101   (->> (Ref 2 (First-five)) (= 2))
    102   (->> (Repeat #f) (Take 3) (List->list) (equal? '(#f #f #f)))
    103   (->> (Repeatedly (lambda () 1))(Take 3)  (List->list)
    104        (equal? '(1 1 1)))
    105   (->> (Iterate add1 0) (Take 3) (List->list) (equal? '(0 1 2)))
    106   (->> (Iterate add1 0) (Length) (eq? #f))
    107   (->> (Append (First-five) (First-five)) (Length) (= 10))
    108   (->> (Append (First-five) (First-five)) (List->list)
    109        (equal? '(0 1 2 3 4 0 1 2 3 4)))
    110   (->> (Append (First-five) (Cardinals)) (Take 12) (List->list)
    111        (equal? '(0 1 2 3 4 0 1 2 3 4 5 6)))
    112   (->> (Append (First-five) (Cardinals)) (Length) (eq? #f))
    113   (->> (First-five) (Reverse) (List->list) (equal? '(4 3 2 1 0)))
    114   (->> (Cardinals) (Take 5) (Reverse) (List->list) (equal? '(4 3 2 1 0)))
    115   (->> (First-five) (Reverse) (Length) (= 5))
    116   (->> (Cardinals) (Reverse*) (Length) (eq? #f))
    117   (->> (Cardinals) (Reverse*) (Ref 5) (List->list) (equal? '(5 4 3 2 1 0)))
    118   (->> (Cycle (First-five)) (Take 10) (List->list)
    119        (equal? '(0 1 2 3 4 0 1 2 3 4)))
    120   (->> (Cycle (First-five)) (Length) (eq? #f))
    121   (->> (Sort < (First-five)) (List->list) (equal? '(0 1 2 3 4)))
    122   (->> (Sort < (First-five)) (Length) (= 5))
    123   (->> (Sort < (List 3 1 0 2 4)) (List->list) (equal? '(0 1 2 3 4)))
     68  (= (Index (cut = <> 2) (First-five)) 2)
     69  (= (Index (cut = <> 20) (First-five)) 5)
     70  (equal? (List->list (Take-upto (cut = <> 5) (Take 10 (Cardinals))))
     71       '(0 1 2 3 4))
     72  (= (Length (Take-upto (cut = <> 5) (Take 10 (Cardinals)))) 5)
     73  (= (Length (Drop-upto (cut = <> 5) (Take 10 (Cardinals)))) 5)
     74  (= (First (Drop-upto (cut = <> 5) (Take 10 (Cardinals)))) 5)
     75  (= (Length (Drop-upto (cut = <> 2) (First-five))) 3)
     76  (= (First (Drop-upto (cut = <> 2) (First-five))) 2)
     77  (equal? (List->list (Memp odd? (First-five))) '(1 2 3 4))
     78  (equal? (List->list (Memv 5 (Take 10 (Cardinals)))) '(5 6 7 8 9))
     79  (equal? (Assv 5 (Take 10 (Map (lambda (x) (list x x)) (Cardinals))))
     80    '(5 5))
     81  (eq? (Assv 10 (Map (lambda (x) (list x x)) (First-five))) #f)
     82  (eq? (Equal? (Cardinals) (Cardinals)) #f)
     83  (eq? (Equal? (Cardinals) (First-five)) #f)
     84  (eq? (Equal? (First-five) (First-five)) #t)
     85  (= (Length (Take 10 (Cardinals))) 10)
     86  (equal? (List->list (Take 5 (Filter odd? (Drop 1 (Cardinals)))))
     87    '(1 3 5 7 9))
     88  (eq? (Length (Cardinals)) #f)
     89  (equal? (List->list (Map add1 (First-five))) '(1 2 3 4 5))
     90  (equal? (List->list (Map + (First-five) (Take 5 (Cardinals))))
     91    '(0 2 4 6 8))
     92  (eq? (Length (Map + (Cardinals) (Cardinals))) #f)
     93  (= (Length (Filter odd? (First-five))) 2)
     94  (equal? (List->list (Filter odd? (First-five))) '(1 3))
     95  (eq? (Length (Filter odd? (Cardinals))) #f)
     96  (= (Ref 20 (Sieve = (Zip (Cardinals) (Cardinals)))) 20)
     97  (equal? (List->list (Sieve = (Zip (First-five) (First-five))))
     98    '(0 1 2 3 4))
     99  (= (Ref 25 (Cardinals)) 25)
     100  (= (Ref 2 (First-five)) 2)
     101  (equal? (List->list (Take 3 (Repeat #f))) '(#f #f #f))
     102  (equal? (List->list (Take 3 (Repeatedly (lambda () 1))))
     103    '(1 1 1))
     104  (equal? (List->list (Take 3 (Iterate add1 0))) '(0 1 2))
     105  (eq? (Length (Iterate add1 0)) #f)
     106  (= (Length (Append (First-five) (First-five))) 10)
     107  (equal? (List->list  (Append (First-five) (First-five)))
     108    '(0 1 2 3 4 0 1 2 3 4))
     109  (equal? (List->list (Take 12 (Append (First-five) (Cardinals))))
     110    '(0 1 2 3 4 0 1 2 3 4 5 6))
     111  (eq? (Length (Append (First-five) (Cardinals))) #f)
     112  (equal? (List->list (Reverse (First-five))) '(4 3 2 1 0))
     113  (equal? (List->list (Reverse (Take 5 (Cardinals)))) '(4 3 2 1 0))
     114  (= (Length (Reverse (First-five))) 5)
     115  (eq? (Length (Reverse* (Cardinals))) #f)
     116  (equal? (List->list (Ref 5 (Reverse* (Cardinals)))) '(5 4 3 2 1 0))
     117  (equal? (List->list (Take 10 (Cycle (First-five))))
     118    '(0 1 2 3 4 0 1 2 3 4))
     119  (eq? (Length (Cycle (First-five))) #f)
     120  (equal? (List->list (Sort < (First-five))) '(0 1 2 3 4))
     121  (= (Length (Sort < (First-five))) 5)
     122  (equal? (List->list (Sort < (List 3 1 0 2 4))) '(0 1 2 3 4))
    124123  (equal?
    125124    (receive (head tail) (Split-at 5 (Cardinals))
     
    130129      (append (List->list tail) (List->list head)))
    131130    '(0 1 2 3 4))
    132   (->> (Cardinals) (Take 5) (Fold-left + 0) (= 10))
    133   (->> (Fold-left + 0 (First-five) (First-five)) (= 20))
    134   (->> (List 1 2 3 4) (Fold-left * 1) (= 24))
    135   (->> (Cardinals) (Take 5) (Fold-left cons '())
    136        (equal? '(((((() . 0) . 1) . 2) . 3) . 4)))
    137   (->> (Cardinals) (Fold-left* cons '()) (Ref 4)
    138        (equal? '(((((() . 0) . 1) . 2) . 3) . 4)))
    139   (->> (Cardinals) (Take 5) (Fold-right + 0) (= 10))
    140   (->> (Fold-right + 0 (First-five) (First-five)) (= 20))
    141   (->> (First-five) (Fold-right cons '())
    142        (equal? '(0 1 2 3 4))) ; list
    143   (->> (First-five) (Fold-right cons '(a b c))
    144        (equal? '(0 1 2 3 4 a b c))) ; append
    145   (->> (Cardinals) (Fold-right* cons '()) (Ref 4)
    146        (equal? '(4 3 2 1 0))) ; note changed order
    147   (->> (Cardinals) (Fold-right* cons-right '()) (Ref 4)
    148        (equal? '(0 1 2 3 4)))
    149   (->> (Cardinals) (Fold-right* cons '(a b c)) (Ref 4)
    150        (equal? '(4 3 2 1 0 a b c))) ; note changed order
    151   (->> (Cardinals) (Fold-right* cons-right '(a b c)) (Ref 4)
    152        (equal? '(a b c 0 1 2 3 4)))
    153   (->> (vector->List '#(0 1 2 3 4)) (List->list) (equal? '(0 1 2 3 4)))
    154   (->> (vector->List '#()) (Null?))
    155   (->> (Take 5 (Cardinals)) (List->vector) (equal? '#(0 1 2 3 4)))
    156   (->> (List->vector (First-five)) (equal? '#(0 1 2 3 4)))
    157   (->> (List->vector Nil) (equal? '#()))
    158   (->> (Filter odd? (Cardinals)) (Take 15) (Every? odd?)
    159        (eq? #t))
    160   (->> (Take 15 (Cardinals)) (Every? odd?)
    161        (eq? #f))
    162   (->> (Every? odd? Nil) (eq? #t))
    163   (->> (Some? odd? Nil) (eq? #f))
    164   (->> (Filter even? (Cardinals)) (Take 5) (Some? odd?)
    165        (eq? #f))
    166   (->> (Some? odd? (First-five)) (eq? #t))
    167   (->> (Zip (Cardinals) (First-five)) (Length) (eq? #f))
    168   (->> (Zip (First-five) (Cardinals)) (Length) (eq? #f))
    169   (->> (Zip (Cardinals) (Cardinals)) (Length) (eq? #f))
    170   (->> (Zip (Cardinals) (First-five)) (Take 14)
    171        (Eqv? (List 0 0 1 1 2 2 3 3 4 4 5 6 7 8)))
    172   (->> (Zip (Cardinals) (Cardinals)) (Take 14)
    173        (Eqv? (List 0 0 1 1 2 2 3 3 4 4 5 5 6 6)))
    174   (->> (Zip (First-five) (First-five)) (Length) (= 10))
    175   (->> (Zip (First-five) (First-five))
    176        (Eqv? (List 0 0 1 1 2 2 3 3 4 4)))
    177   (->> (Primes) (Ref 50) (= 233))
    178   (->> (Primes) (Take 5) (Eqv? (List 2 3 5 7 11)))
    179   (->> (Fibs) (Take 10) (Eqv? (List  0 1 1 2 3 5 8 13 21 34)))
     131  (= (Fold-left + 0 (Take 5 (Cardinals))) 10)
     132  (= (Fold-left + 0 (First-five) (First-five)) 20)
     133  (= (Fold-left * 1 (List 1 2 3 4)) 24)
     134  (equal? (Fold-left cons '() (Take 5 (Cardinals)))
     135    '(((((() . 0) . 1) . 2) . 3) . 4))
     136  (equal? (Ref 4 (Fold-left* cons '() (Cardinals)))
     137    '(((((() . 0) . 1) . 2) . 3) . 4))
     138  (= (Fold-right + 0 (Take 5 (Cardinals))) 10)
     139  (= (Fold-right + 0 (First-five) (First-five)) 20)
     140  (equal? (Fold-right cons '() (First-five))
     141    '(0 1 2 3 4)) ; list
     142  (equal? (Fold-right cons '(a b c) (First-five))
     143    '(0 1 2 3 4 a b c)) ; append
     144  (equal? (Ref 4 (Fold-right* cons '() (Cardinals)))
     145    '(4 3 2 1 0)) ; note changed order
     146  (equal? (Ref 4 (Fold-right* cons-right '() (Cardinals)))
     147    '(0 1 2 3 4))
     148  (equal? (Ref 4 (Fold-right* cons '(a b c) (Cardinals)))
     149    '(4 3 2 1 0 a b c)) ; note changed order
     150  (equal? (Ref 4 (Fold-right* cons-right '(a b c) (Cardinals)))
     151    '(a b c 0 1 2 3 4))
     152  (equal? (List->list (vector->List '#(0 1 2 3 4))) '(0 1 2 3 4))
     153  (Null? (vector->List '#()))
     154  (equal? (List->vector (Take 5 (Cardinals))) '#(0 1 2 3 4))
     155  (equal? (List->vector (First-five)) '#(0 1 2 3 4))
     156  (equal? (List->vector Nil) '#())
     157  (eq? (Every? odd? (Take 15 (Filter odd? (Cardinals)))) #t)
     158  (eq? (Every? odd? (Take 15 (Cardinals))) #f)
     159  (eq? (Every? odd? Nil) #t)
     160  (eq? (Some? odd? Nil) #f)
     161  (eq? (Some? odd? (Take 5 (Filter even? (Cardinals)))) #f)
     162  (eq? (Some? odd? (First-five)) #t)
     163  (eq? (Length (Zip (Cardinals) (First-five))) #f)
     164  (eq? (Length (Zip (First-five) (Cardinals))) #f)
     165  (eq? (Length (Zip (Cardinals) (Cardinals))) #f)
     166  (= (Length (Zip (First-five) (First-five))) 10)
     167  (Eqv? (Take 14 (Zip (Cardinals) (First-five)))
     168    (List 0 0 1 1 2 2 3 3 4 4 5 6 7 8))
     169  (Eqv? (Take 14 (Zip (Cardinals) (Cardinals)))
     170    (List 0 0 1 1 2 2 3 3 4 4 5 5 6 6))
     171  (Eqv? (Zip (First-five) (First-five))
     172    (List 0 0 1 1 2 2 3 3 4 4))
     173  (= (Ref 50 (Primes)) 233)
     174  (Eqv? (Take 5 (Primes)) (List 2 3 5 7 11))
     175  (Eqv? (Take 10 (Fibs)) (List  0 1 1 2 3 5 8 13 21 34))
    180176  ;; compute square root
    181177  (let ((eps 0.000001))
    182178    (< (abs (- (sqrt 2) (Within eps (Iterate (Newton 2) 2)))) eps))
    183   (->> (First-five) (Sums) (List->list) (equal? '(0 1 3 6 10)))
     179  (equal? (List->list (Sums (First-five))) '(0 1 3 6 10))
    184180  )
    185181
  • release/4/lazy-lists/trunk/lazy-lists.meta

    r27153 r27200  
    33((synopsis "implementation of lazy lists")
    44 (category data)
    5  (depends contracts records)
     5 (depends contracts)
    66 (license "BSD")
    7  (doc-from-wiki #t)
    8  (author "Juergen Lorenz")
    9  (files "lazy-lists.setup" "lazy-lists.release-info" "lazy-lists.meta" "lazy-lists.scm" "tests/run.scm"))
     7 (author "Juergen Lorenz"))
  • release/4/lazy-lists/trunk/lazy-lists.scm

    r27153 r27200  
    523523) ; module %lazy-lists
    524524
    525 ;;(define (Take-with ok? seq)
    526 ;;  (let loop ((n 1) (seq seq))
    527 ;;    (print n);;;
    528 ;;    (if (or (Null? seq) (ok? (First seq)))
    529 ;;      Nil
    530 ;;      (Lazy n
    531 ;;        (cons (First seq) (loop (+ n 1) (Rest seq)))))))
    532 ;(define (First-five) (List 0 1 2 3 4))
    533 ;(define (Index ok? seq)
    534 ;  (let loop ((n 0) (seq seq))
    535 ;    (cond
    536 ;      ((Null? seq) #f)
    537 ;      ((ok? (First seq)) n)
    538 ;      (else (loop (+ n 1) (Rest seq))))))
    539 ;;(receive (head tail) (Split-at (Index (cut = <> 3) (List 0 1 2 3 4))
    540 ;;                               (List 0 1 2 3 4))
    541 ;;  (print (List->list head) " " (List->list tail)))
    542 
    543525(module lazy-lists
    544526  (Lazy make-lazy Car Cdr Nil Cons
     
    564546
    565547;; initialize documentation
    566 (doclist '())
     548(doclist '((Nil  "empty lazy list")))
    567549
    568550(define-syntax-with-contract Lazy
     
    603585  (%List xpr))
    604586
    605 (define Nil %Nil)
     587(define Nil
     588  %Nil)
    606589
    607590(define-with-contract (Interval from upto)
  • release/4/lazy-lists/trunk/lazy-lists.setup

    r27153 r27200  
    22
    33(compile -O2 -s -d1 lazy-lists.scm -J)
    4 (compile -O2 -d0 -s lazy-lists.import.scm)
    5 (compile -O2 -d0 -s %lazy-lists.import.scm)
     4(compile -O3 -d0 -s lazy-lists.import.scm)
     5(compile -O3 -d0 -s %lazy-lists.import.scm)
    66
    77(install-extension
    88 'lazy-lists
    99 '("lazy-lists.so" "lazy-lists.import.so" "%lazy-lists.import.so")
    10  '((version "0.1")))
     10 '((version "0.2")))
  • release/4/lazy-lists/trunk/tests/run.scm

    r27153 r27200  
    1 (require-library lazy-lists clojurian-syntax)
    2 (import lazy-lists clojurian-syntax)
     1(require-library lazy-lists)
     2(import lazy-lists)
    33
    44;;; (run xpr0 xpr1 ...)
     
    4848  (= (Length (First-five)) 5)
    4949  (= (Length (Rest (First-five))) 4)
    50   (->> (Cardinals) (Rest) (Length) (eq? #f))
    51   (->> (Cardinals) (Take 5) (Length) (= 5))
    52   (->> (Cardinals) (Length) (eq? #f))
    53   (->> (Cardinals) (Drop 5) (Length) (eq? #f))
    54   (->> (Cardinals) (Drop 5) (First) (= 5))
    55   (->> (First-five) (List->list) (equal? '(0 1 2 3 4)))
    56   (->> (Cardinals) (Take 5) (List->list) (equal? '(0 1 2 3 4)))
    57   (->> (Interval 2 10) (Length) (= (- 10 2)))
    58   (->> (Interval 2 10) (List->list) (equal? '(2 3 4 5 6 7 8 9)))
    59   (->> (Interval 10 2) (List->list) (equal? '(10 9 8 7 6 5 4 3)))
     50  (eq? (Length (Rest (Cardinals))) #f)
     51  (= (Length (Take 5 (Cardinals))) 5)
     52  (eq? (Length (Cardinals)) #f)
     53  (eq? (Length (Drop 5 (Cardinals))) #f)
     54  (= (First (Drop 5 (Cardinals))) 5)
     55  (equal? (List->list (First-five)) '(0 1 2 3 4))
     56  (equal? (List->list (Take 5 (Cardinals))) '(0 1 2 3 4))
     57  (= (Length (Interval 2 10)) (- 10 2))
     58  (equal? (List->list (Interval 2 10)) '(2 3 4 5 6 7 8 9))
     59  (equal? (List->list (Interval 10 2)) '(10 9 8 7 6 5 4 3))
    6060  (equal?
    6161    (receive (head index tail) (Split-with (cut = <> 3) (First-five))
     
    6666      (append (List->list tail) (List->list head)))
    6767    '(5 6 7 8 9 0 1 2 3 4))
    68   (->> (First-five) (Index (cut = <> 2)) (= 2))
    69   (->> (First-five) (Index (cut = <> 20)) (= 5))
    70   (->> (Cardinals) (Take 10) (Take-upto (cut = <> 5)) (List->list)
    71        (equal? '(0 1 2 3 4)))
    72   (->> (Cardinals) (Take 10) (Take-upto (cut = <> 5)) (Length) (= 5))
    73   (->> (Cardinals) (Take 10) (Drop-upto (cut = <> 5)) (Length) (= 5))
    74   (->> (Cardinals) (Take 10) (Drop-upto (cut = <> 5)) (First) (= 5))
    75   (->> (First-five) (Drop-upto (cut = <> 2)) (Length) (= 3))
    76   (->> (First-five) (Drop-upto (cut = <> 2)) (First) (= 2))
    77   (->> (First-five) (Memp odd?) (List->list) (equal? '(1 2 3 4)))
    78   (->> (Cardinals) (Take 10) (Memv 5) (List->list) (equal? '(5 6 7 8 9)))
    79   (->> (Cardinals) (Map (lambda (x) (list x x))) (Take 10) (Assv 5)
    80        (equal? '(5 5)))
    81   (->> (First-five) (Map (lambda (x) (list x x))) (Assv 10)
    82        (eq? #f))
    83   (->> (Cardinals) (Equal? (Cardinals)) (eq? #f))
    84   (->> (Cardinals) (Equal? (First-five)) (eq? #f))
    85   (->> (First-five) (Equal? (First-five)) (eq? #t))
    86   (->> (Cardinals) (Take 10) (Length) (= 10))
    87   (->> (Cardinals) (Drop 1) (Filter odd?) (Take 5) (List->list)
    88        (equal? '(1 3 5 7 9)))
    89   (->> (Cardinals) (Length) (eq? #f))
    90   (->> (First-five) (Map add1) (List->list) (equal? '(1 2 3 4 5)))
    91   (->> (Map + (First-five) (Take 5 (Cardinals))) (List->list)
    92        (equal? '(0 2 4 6 8)))
    93   (->> (Map + (Cardinals) (Cardinals)) (Length) (eq? #f))
    94   (->> (Filter odd? (First-five)) (Length) (= 2))
    95   (->> (Filter odd? (First-five)) (List->list) (equal? '(1 3)))
    96   (->> (Filter odd? (Cardinals)) (Length) (eq? #f))
    97   (->> (Zip (Cardinals) (Cardinals)) (Sieve =) (Ref 20) (= 20))
    98   (->> (Zip (First-five) (First-five)) (Sieve =) (List->list)
    99        (equal? '(0 1 2 3 4)))
    100   (->> (Ref 25 (Cardinals)) (= 25))
    101   (->> (Ref 2 (First-five)) (= 2))
    102   (->> (Repeat #f) (Take 3) (List->list) (equal? '(#f #f #f)))
    103   (->> (Repeatedly (lambda () 1))(Take 3)  (List->list)
    104        (equal? '(1 1 1)))
    105   (->> (Iterate add1 0) (Take 3) (List->list) (equal? '(0 1 2)))
    106   (->> (Iterate add1 0) (Length) (eq? #f))
    107   (->> (Append (First-five) (First-five)) (Length) (= 10))
    108   (->> (Append (First-five) (First-five)) (List->list)
    109        (equal? '(0 1 2 3 4 0 1 2 3 4)))
    110   (->> (Append (First-five) (Cardinals)) (Take 12) (List->list)
    111        (equal? '(0 1 2 3 4 0 1 2 3 4 5 6)))
    112   (->> (Append (First-five) (Cardinals)) (Length) (eq? #f))
    113   (->> (First-five) (Reverse) (List->list) (equal? '(4 3 2 1 0)))
    114   (->> (Cardinals) (Take 5) (Reverse) (List->list) (equal? '(4 3 2 1 0)))
    115   (->> (First-five) (Reverse) (Length) (= 5))
    116   (->> (Cardinals) (Reverse*) (Length) (eq? #f))
    117   (->> (Cardinals) (Reverse*) (Ref 5) (List->list) (equal? '(5 4 3 2 1 0)))
    118   (->> (Cycle (First-five)) (Take 10) (List->list)
    119        (equal? '(0 1 2 3 4 0 1 2 3 4)))
    120   (->> (Cycle (First-five)) (Length) (eq? #f))
    121   (->> (Sort < (First-five)) (List->list) (equal? '(0 1 2 3 4)))
    122   (->> (Sort < (First-five)) (Length) (= 5))
    123   (->> (Sort < (List 3 1 0 2 4)) (List->list) (equal? '(0 1 2 3 4)))
     68  (= (Index (cut = <> 2) (First-five)) 2)
     69  (= (Index (cut = <> 20) (First-five)) 5)
     70  (equal? (List->list (Take-upto (cut = <> 5) (Take 10 (Cardinals))))
     71       '(0 1 2 3 4))
     72  (= (Length (Take-upto (cut = <> 5) (Take 10 (Cardinals)))) 5)
     73  (= (Length (Drop-upto (cut = <> 5) (Take 10 (Cardinals)))) 5)
     74  (= (First (Drop-upto (cut = <> 5) (Take 10 (Cardinals)))) 5)
     75  (= (Length (Drop-upto (cut = <> 2) (First-five))) 3)
     76  (= (First (Drop-upto (cut = <> 2) (First-five))) 2)
     77  (equal? (List->list (Memp odd? (First-five))) '(1 2 3 4))
     78  (equal? (List->list (Memv 5 (Take 10 (Cardinals)))) '(5 6 7 8 9))
     79  (equal? (Assv 5 (Take 10 (Map (lambda (x) (list x x)) (Cardinals))))
     80    '(5 5))
     81  (eq? (Assv 10 (Map (lambda (x) (list x x)) (First-five))) #f)
     82  (eq? (Equal? (Cardinals) (Cardinals)) #f)
     83  (eq? (Equal? (Cardinals) (First-five)) #f)
     84  (eq? (Equal? (First-five) (First-five)) #t)
     85  (= (Length (Take 10 (Cardinals))) 10)
     86  (equal? (List->list (Take 5 (Filter odd? (Drop 1 (Cardinals)))))
     87    '(1 3 5 7 9))
     88  (eq? (Length (Cardinals)) #f)
     89  (equal? (List->list (Map add1 (First-five))) '(1 2 3 4 5))
     90  (equal? (List->list (Map + (First-five) (Take 5 (Cardinals))))
     91    '(0 2 4 6 8))
     92  (eq? (Length (Map + (Cardinals) (Cardinals))) #f)
     93  (= (Length (Filter odd? (First-five))) 2)
     94  (equal? (List->list (Filter odd? (First-five))) '(1 3))
     95  (eq? (Length (Filter odd? (Cardinals))) #f)
     96  (= (Ref 20 (Sieve = (Zip (Cardinals) (Cardinals)))) 20)
     97  (equal? (List->list (Sieve = (Zip (First-five) (First-five))))
     98    '(0 1 2 3 4))
     99  (= (Ref 25 (Cardinals)) 25)
     100  (= (Ref 2 (First-five)) 2)
     101  (equal? (List->list (Take 3 (Repeat #f))) '(#f #f #f))
     102  (equal? (List->list (Take 3 (Repeatedly (lambda () 1))))
     103    '(1 1 1))
     104  (equal? (List->list (Take 3 (Iterate add1 0))) '(0 1 2))
     105  (eq? (Length (Iterate add1 0)) #f)
     106  (= (Length (Append (First-five) (First-five))) 10)
     107  (equal? (List->list  (Append (First-five) (First-five)))
     108    '(0 1 2 3 4 0 1 2 3 4))
     109  (equal? (List->list (Take 12 (Append (First-five) (Cardinals))))
     110    '(0 1 2 3 4 0 1 2 3 4 5 6))
     111  (eq? (Length (Append (First-five) (Cardinals))) #f)
     112  (equal? (List->list (Reverse (First-five))) '(4 3 2 1 0))
     113  (equal? (List->list (Reverse (Take 5 (Cardinals)))) '(4 3 2 1 0))
     114  (= (Length (Reverse (First-five))) 5)
     115  (eq? (Length (Reverse* (Cardinals))) #f)
     116  (equal? (List->list (Ref 5 (Reverse* (Cardinals)))) '(5 4 3 2 1 0))
     117  (equal? (List->list (Take 10 (Cycle (First-five))))
     118    '(0 1 2 3 4 0 1 2 3 4))
     119  (eq? (Length (Cycle (First-five))) #f)
     120  (equal? (List->list (Sort < (First-five))) '(0 1 2 3 4))
     121  (= (Length (Sort < (First-five))) 5)
     122  (equal? (List->list (Sort < (List 3 1 0 2 4))) '(0 1 2 3 4))
    124123  (equal?
    125124    (receive (head tail) (Split-at 5 (Cardinals))
     
    130129      (append (List->list tail) (List->list head)))
    131130    '(0 1 2 3 4))
    132   (->> (Cardinals) (Take 5) (Fold-left + 0) (= 10))
    133   (->> (Fold-left + 0 (First-five) (First-five)) (= 20))
    134   (->> (List 1 2 3 4) (Fold-left * 1) (= 24))
    135   (->> (Cardinals) (Take 5) (Fold-left cons '())
    136        (equal? '(((((() . 0) . 1) . 2) . 3) . 4)))
    137   (->> (Cardinals) (Fold-left* cons '()) (Ref 4)
    138        (equal? '(((((() . 0) . 1) . 2) . 3) . 4)))
    139   (->> (Cardinals) (Take 5) (Fold-right + 0) (= 10))
    140   (->> (Fold-right + 0 (First-five) (First-five)) (= 20))
    141   (->> (First-five) (Fold-right cons '())
    142        (equal? '(0 1 2 3 4))) ; list
    143   (->> (First-five) (Fold-right cons '(a b c))
    144        (equal? '(0 1 2 3 4 a b c))) ; append
    145   (->> (Cardinals) (Fold-right* cons '()) (Ref 4)
    146        (equal? '(4 3 2 1 0))) ; note changed order
    147   (->> (Cardinals) (Fold-right* cons-right '()) (Ref 4)
    148        (equal? '(0 1 2 3 4)))
    149   (->> (Cardinals) (Fold-right* cons '(a b c)) (Ref 4)
    150        (equal? '(4 3 2 1 0 a b c))) ; note changed order
    151   (->> (Cardinals) (Fold-right* cons-right '(a b c)) (Ref 4)
    152        (equal? '(a b c 0 1 2 3 4)))
    153   (->> (vector->List '#(0 1 2 3 4)) (List->list) (equal? '(0 1 2 3 4)))
    154   (->> (vector->List '#()) (Null?))
    155   (->> (Take 5 (Cardinals)) (List->vector) (equal? '#(0 1 2 3 4)))
    156   (->> (List->vector (First-five)) (equal? '#(0 1 2 3 4)))
    157   (->> (List->vector Nil) (equal? '#()))
    158   (->> (Filter odd? (Cardinals)) (Take 15) (Every? odd?)
    159        (eq? #t))
    160   (->> (Take 15 (Cardinals)) (Every? odd?)
    161        (eq? #f))
    162   (->> (Every? odd? Nil) (eq? #t))
    163   (->> (Some? odd? Nil) (eq? #f))
    164   (->> (Filter even? (Cardinals)) (Take 5) (Some? odd?)
    165        (eq? #f))
    166   (->> (Some? odd? (First-five)) (eq? #t))
    167   (->> (Zip (Cardinals) (First-five)) (Length) (eq? #f))
    168   (->> (Zip (First-five) (Cardinals)) (Length) (eq? #f))
    169   (->> (Zip (Cardinals) (Cardinals)) (Length) (eq? #f))
    170   (->> (Zip (Cardinals) (First-five)) (Take 14)
    171        (Eqv? (List 0 0 1 1 2 2 3 3 4 4 5 6 7 8)))
    172   (->> (Zip (Cardinals) (Cardinals)) (Take 14)
    173        (Eqv? (List 0 0 1 1 2 2 3 3 4 4 5 5 6 6)))
    174   (->> (Zip (First-five) (First-five)) (Length) (= 10))
    175   (->> (Zip (First-five) (First-five))
    176        (Eqv? (List 0 0 1 1 2 2 3 3 4 4)))
    177   (->> (Primes) (Ref 50) (= 233))
    178   (->> (Primes) (Take 5) (Eqv? (List 2 3 5 7 11)))
    179   (->> (Fibs) (Take 10) (Eqv? (List  0 1 1 2 3 5 8 13 21 34)))
     131  (= (Fold-left + 0 (Take 5 (Cardinals))) 10)
     132  (= (Fold-left + 0 (First-five) (First-five)) 20)
     133  (= (Fold-left * 1 (List 1 2 3 4)) 24)
     134  (equal? (Fold-left cons '() (Take 5 (Cardinals)))
     135    '(((((() . 0) . 1) . 2) . 3) . 4))
     136  (equal? (Ref 4 (Fold-left* cons '() (Cardinals)))
     137    '(((((() . 0) . 1) . 2) . 3) . 4))
     138  (= (Fold-right + 0 (Take 5 (Cardinals))) 10)
     139  (= (Fold-right + 0 (First-five) (First-five)) 20)
     140  (equal? (Fold-right cons '() (First-five))
     141    '(0 1 2 3 4)) ; list
     142  (equal? (Fold-right cons '(a b c) (First-five))
     143    '(0 1 2 3 4 a b c)) ; append
     144  (equal? (Ref 4 (Fold-right* cons '() (Cardinals)))
     145    '(4 3 2 1 0)) ; note changed order
     146  (equal? (Ref 4 (Fold-right* cons-right '() (Cardinals)))
     147    '(0 1 2 3 4))
     148  (equal? (Ref 4 (Fold-right* cons '(a b c) (Cardinals)))
     149    '(4 3 2 1 0 a b c)) ; note changed order
     150  (equal? (Ref 4 (Fold-right* cons-right '(a b c) (Cardinals)))
     151    '(a b c 0 1 2 3 4))
     152  (equal? (List->list (vector->List '#(0 1 2 3 4))) '(0 1 2 3 4))
     153  (Null? (vector->List '#()))
     154  (equal? (List->vector (Take 5 (Cardinals))) '#(0 1 2 3 4))
     155  (equal? (List->vector (First-five)) '#(0 1 2 3 4))
     156  (equal? (List->vector Nil) '#())
     157  (eq? (Every? odd? (Take 15 (Filter odd? (Cardinals)))) #t)
     158  (eq? (Every? odd? (Take 15 (Cardinals))) #f)
     159  (eq? (Every? odd? Nil) #t)
     160  (eq? (Some? odd? Nil) #f)
     161  (eq? (Some? odd? (Take 5 (Filter even? (Cardinals)))) #f)
     162  (eq? (Some? odd? (First-five)) #t)
     163  (eq? (Length (Zip (Cardinals) (First-five))) #f)
     164  (eq? (Length (Zip (First-five) (Cardinals))) #f)
     165  (eq? (Length (Zip (Cardinals) (Cardinals))) #f)
     166  (= (Length (Zip (First-five) (First-five))) 10)
     167  (Eqv? (Take 14 (Zip (Cardinals) (First-five)))
     168    (List 0 0 1 1 2 2 3 3 4 4 5 6 7 8))
     169  (Eqv? (Take 14 (Zip (Cardinals) (Cardinals)))
     170    (List 0 0 1 1 2 2 3 3 4 4 5 5 6 6))
     171  (Eqv? (Zip (First-five) (First-five))
     172    (List 0 0 1 1 2 2 3 3 4 4))
     173  (= (Ref 50 (Primes)) 233)
     174  (Eqv? (Take 5 (Primes)) (List 2 3 5 7 11))
     175  (Eqv? (Take 10 (Fibs)) (List  0 1 1 2 3 5 8 13 21 34))
    180176  ;; compute square root
    181177  (let ((eps 0.000001))
    182178    (< (abs (- (sqrt 2) (Within eps (Iterate (Newton 2) 2)))) eps))
    183   (->> (First-five) (Sums) (List->list) (equal? '(0 1 3 6 10)))
     179  (equal? (List->list (Sums (First-five))) '(0 1 3 6 10))
    184180  )
    185181
Note: See TracChangeset for help on using the changeset viewer.