Changeset 37756 in project


Ignore:
Timestamp:
07/04/19 17:31:13 (13 days ago)
Author:
juergen
Message:

biglists 0.2 with change in syntax of For

Location:
release/5/biglists
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • release/5/biglists/tags/0.2/biglists.egg

    r37454 r37756  
    66 (dependencies bindings)
    77 (author "[[Juergen Lorenz]]")
    8  (version "0.1.2")
     8 (version "0.2")
    99 (components (extension biglists)))
    1010
  • release/5/biglists/tags/0.2/biglists.scm

    r37454 r37756  
    11121112    ))
    11131113
    1114 ;;; (For ((var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...) item-xpr)
    1115 ;;; ---------------------------------------------------------------
     1114;;; (For item-xpr (var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...)
     1115;;; -------------------------------------------------------------
    11161116(define-syntax For
    11171117  (syntax-rules ()
    1118    ((_ ((var xs ok-xpr ...)) item-xpr)
     1118   ((_ item-xpr (var xs ok-xpr ...))
    11191119    (cond
    11201120      ((Eager? xs)
     
    11351135               (recur (Rest seq)))))))
    11361136      (else (error 'For "not a biglist" xs))))
    1137     ((_ ((var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...) item-xpr)
     1137    ((_ item-xpr (var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...)
    11381138     (let recur ((seq xs))
    11391139       (if (Null? seq)
     
    11441144         (let ((var (First seq)))
    11451145           (if (and ok-xpr ...)
    1146              (Append (For ((var1 xs1 ok-xpr1 ...) ...) item-xpr)
     1146             (Append (For item-xpr (var1 xs1 ok-xpr1 ...) ...)
    11471147                     (recur (Rest seq)))
    11481148             (recur (Rest seq)))))))
     
    13091309    (For
    13101310      macro:
    1311       (For ((var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...) item-xpr)
     1311      (For item-xpr (var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...)
    13121312      "creates a new list by binding var to each element"
    13131313      "of the list xs in sequence, and if it passes the checks,"
  • release/5/biglists/tags/0.2/tests/run.scm

    r37397 r37756  
    244244          '(1 2 3 4 5))
    245245  (Print five)
    246   (equal? (BigList->list (For ((x four)) (add1 x)))
     246  (equal? (BigList->list (For (add1 x) (x four)))
    247247          '(1 2 3 4)); map
    248248  (equal? (BigList->list
    249             (For ((x (List 0 1 2 3 4 5 6) (odd? x))) x)) ; filter
     249            (For x (x (List 0 1 2 3 4 5 6) (odd? x)))) ; filter
    250250          '(1 3 5))
    251251  (equal? (BigList->list
    252             (For ((n (List 0 1 2 3 4 5 6) (positive? n) (even? n)))
    253                (* 10 n)))
     252            (For (* 10 n)
     253                 (n (List 0 1 2 3 4 5 6) (positive? n) (even?  n))))
    254254          '(20 40 60))
    255255  (equal? (BigList->list
    256             (For ((c (List 'A 'B 'C)) ;lazy
    257                   (k '(1 2 3 4))) ;eager
    258               (list c k)))
    259           '((A 1) (A 2) (A 3) (A 4)
    260                   (B 1) (B 2) (B 3) (B 4)
    261                   (C 1) (C 2) (C 3) (C 4)))
    262   (equal? (BigList->list
    263             (For ((c (List 'A 'B 'C)) ;lazy
    264                   (k (List 1 2 3 4))) ;lazy
    265               (list c k)))
    266           '((A 1) (A 2) (A 3) (A 4)
    267             (B 1) (B 2) (B 3) (B 4)
    268             (C 1) (C 2) (C 3) (C 4)))
    269   (equal? (For ((c '(A B C)) ;eager
    270                 (k (List 1 2 3 4))) ;lazy
    271             (list c k))
    272           '((A 1) (A 2) (A 3) (A 4)
    273             (B 1) (B 2) (B 3) (B 4)
    274             (C 1) (C 2) (C 3) (C 4)))
    275   (equal? (For ((c '(A B C)) ;eager
    276                 (k '(1 2 3 4))) ;eager
    277             (list c k))
     256            (For (list c k)
     257                 (c (List 'A 'B 'C)) ;lazy
     258                 (k '(1 2 3 4)))) ;eager
     259          '((A 1) (A 2) (A 3) (A 4)
     260            (B 1) (B 2) (B 3) (B 4)
     261            (C 1) (C 2) (C 3) (C 4)))
     262  (equal? (BigList->list
     263            (For (list c k)
     264                 (c (List 'A 'B 'C)) ;lazy
     265                 (k (List 1 2 3 4)))) ;lazy
     266          '((A 1) (A 2) (A 3) (A 4)
     267            (B 1) (B 2) (B 3) (B 4)
     268            (C 1) (C 2) (C 3) (C 4)))
     269  (equal? (For (list c k)
     270               (c '(A B C)) ;eager
     271               (k (List 1 2 3 4))) ;lazy
     272          '((A 1) (A 2) (A 3) (A 4)
     273            (B 1) (B 2) (B 3) (B 4)
     274            (C 1) (C 2) (C 3) (C 4)))
     275  (equal? (For (list c k)
     276               (c '(A B C)) ;eager
     277               (k '(1 2 3 4))) ;eager
    278278          '((A 1) (A 2) (A 3) (A 4)
    279279            (B 1) (B 2) (B 3) (B 4)
  • release/5/biglists/trunk/biglists.egg

    r37454 r37756  
    66 (dependencies bindings)
    77 (author "[[Juergen Lorenz]]")
    8  (version "0.1.2")
     8 (version "0.2")
    99 (components (extension biglists)))
    1010
  • release/5/biglists/trunk/biglists.scm

    r37454 r37756  
    11121112    ))
    11131113
    1114 ;;; (For ((var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...) item-xpr)
    1115 ;;; ---------------------------------------------------------------
     1114;;; (For item-xpr (var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...)
     1115;;; -------------------------------------------------------------
    11161116(define-syntax For
    11171117  (syntax-rules ()
    1118    ((_ ((var xs ok-xpr ...)) item-xpr)
     1118   ((_ item-xpr (var xs ok-xpr ...))
    11191119    (cond
    11201120      ((Eager? xs)
     
    11351135               (recur (Rest seq)))))))
    11361136      (else (error 'For "not a biglist" xs))))
    1137     ((_ ((var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...) item-xpr)
     1137    ((_ item-xpr (var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...)
    11381138     (let recur ((seq xs))
    11391139       (if (Null? seq)
     
    11441144         (let ((var (First seq)))
    11451145           (if (and ok-xpr ...)
    1146              (Append (For ((var1 xs1 ok-xpr1 ...) ...) item-xpr)
     1146             (Append (For item-xpr (var1 xs1 ok-xpr1 ...) ...)
    11471147                     (recur (Rest seq)))
    11481148             (recur (Rest seq)))))))
     
    13091309    (For
    13101310      macro:
    1311       (For ((var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...) item-xpr)
     1311      (For item-xpr (var xs ok-xpr ...) (var1 xs1 ok-xpr1 ...) ...)
    13121312      "creates a new list by binding var to each element"
    13131313      "of the list xs in sequence, and if it passes the checks,"
  • release/5/biglists/trunk/tests/run.scm

    r37397 r37756  
    244244          '(1 2 3 4 5))
    245245  (Print five)
    246   (equal? (BigList->list (For ((x four)) (add1 x)))
     246  (equal? (BigList->list (For (add1 x) (x four)))
    247247          '(1 2 3 4)); map
    248248  (equal? (BigList->list
    249             (For ((x (List 0 1 2 3 4 5 6) (odd? x))) x)) ; filter
     249            (For x (x (List 0 1 2 3 4 5 6) (odd? x)))) ; filter
    250250          '(1 3 5))
    251251  (equal? (BigList->list
    252             (For ((n (List 0 1 2 3 4 5 6) (positive? n) (even? n)))
    253                (* 10 n)))
     252            (For (* 10 n)
     253                 (n (List 0 1 2 3 4 5 6) (positive? n) (even?  n))))
    254254          '(20 40 60))
    255255  (equal? (BigList->list
    256             (For ((c (List 'A 'B 'C)) ;lazy
    257                   (k '(1 2 3 4))) ;eager
    258               (list c k)))
    259           '((A 1) (A 2) (A 3) (A 4)
    260                   (B 1) (B 2) (B 3) (B 4)
    261                   (C 1) (C 2) (C 3) (C 4)))
    262   (equal? (BigList->list
    263             (For ((c (List 'A 'B 'C)) ;lazy
    264                   (k (List 1 2 3 4))) ;lazy
    265               (list c k)))
    266           '((A 1) (A 2) (A 3) (A 4)
    267             (B 1) (B 2) (B 3) (B 4)
    268             (C 1) (C 2) (C 3) (C 4)))
    269   (equal? (For ((c '(A B C)) ;eager
    270                 (k (List 1 2 3 4))) ;lazy
    271             (list c k))
    272           '((A 1) (A 2) (A 3) (A 4)
    273             (B 1) (B 2) (B 3) (B 4)
    274             (C 1) (C 2) (C 3) (C 4)))
    275   (equal? (For ((c '(A B C)) ;eager
    276                 (k '(1 2 3 4))) ;eager
    277             (list c k))
     256            (For (list c k)
     257                 (c (List 'A 'B 'C)) ;lazy
     258                 (k '(1 2 3 4)))) ;eager
     259          '((A 1) (A 2) (A 3) (A 4)
     260            (B 1) (B 2) (B 3) (B 4)
     261            (C 1) (C 2) (C 3) (C 4)))
     262  (equal? (BigList->list
     263            (For (list c k)
     264                 (c (List 'A 'B 'C)) ;lazy
     265                 (k (List 1 2 3 4)))) ;lazy
     266          '((A 1) (A 2) (A 3) (A 4)
     267            (B 1) (B 2) (B 3) (B 4)
     268            (C 1) (C 2) (C 3) (C 4)))
     269  (equal? (For (list c k)
     270               (c '(A B C)) ;eager
     271               (k (List 1 2 3 4))) ;lazy
     272          '((A 1) (A 2) (A 3) (A 4)
     273            (B 1) (B 2) (B 3) (B 4)
     274            (C 1) (C 2) (C 3) (C 4)))
     275  (equal? (For (list c k)
     276               (c '(A B C)) ;eager
     277               (k '(1 2 3 4))) ;eager
    278278          '((A 1) (A 2) (A 3) (A 4)
    279279            (B 1) (B 2) (B 3) (B 4)
Note: See TracChangeset for help on using the changeset viewer.