Changeset 31264 in project


Ignore:
Timestamp:
08/22/14 13:02:20 (7 years ago)
Author:
juergen
Message:

typed-lists functor split in two

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

Legend:

Unmodified
Added
Removed
  • release/4/typed-lists/tags/1.3/tests/run.scm

    r31238 r31264  
    11(require-library cells simple-tests datatype)
    2 (import typed-lists simple-tests datatype)
     2(import typed-lists typed-sets simple-tests datatype)
    33
    44(define-test (number-lists?)
    55  (check
    66    ;; argument module
    7     (module nums (type? equ?)
     7    (module numbers (type? equ?)
    88      (import scheme cells)
    99      (define (type? x)
     
    2020
    2121    ;; apply functor
    22     (module lists = (typed-lists nums))
     22    (module lists = (typed-lists numbers))
    2323   
    2424    ;; import
     
    166166    ))
    167167
    168 (define-test (sets?)
    169   (check
    170 ;    ;; argument module
    171 ;    (module any (type? equ?)
    172 ;      (import scheme)
    173 ;      (define (type? x) #t)
    174 ;      (define (equ? x y) (equal? x y))
    175 ;      )
    176 ;    ;; apply functor
    177 ;    (module any-lists = (typed-lists any))
    178 ;    ;; import
    179 ;    (import any-lists)
    180     (aset=
    181       (atyped-list->set (atyped-list 1 2 1 3 2 3))
    182       (aset 3 2 1))
    183     (aset? (aset 1 2 3))
    184     (aset? (aset 1 2 2 3))
    185     (aset= (aset 2 1 3) (aset 1 2 2 3))
    186     (aset-in? 2 (aset 1 1 2 3))
    187     (aset<= (aset 2 1 2) (aset 4 1 2 3 4))
    188     (aset=
    189       (aset-add 0 (aset 1 2 3))
    190       (aset 0 1 2 3))
    191     (aset=
    192       (aset-add 2 (aset 1 2 3))
    193       (aset 1 2 3))
    194     (= (aset-cardinality (aset 2 1 2 3 2)) 3)
    195     (aset=
    196       (aset-remove 2 (aset 2 1 2 3 2))
    197       (aset 1 3))
    198     (aset=
    199       (aset 0 1 1 0 2 3 2)
    200       (aset 2 3 0 1))
    201     (aset=
    202       (aset-difference (aset 0 2 1 3) (aset 1 1))
    203       (aset 0 2 3))
    204     (aset=
    205       (aset-union (aset 1 2) (aset 2 3) (aset 3 4))
    206       (aset 1 2 3 4))
    207     (aset=
    208       (aset-intersection (aset 1 2 3 4) (aset 2 3 5) (aset 3 4))
    209       (aset 3))
    210     (aset= (aset-filter odd? (aset 2 1 3 3 1 1)) (aset 3 1))
    211     ))
    212 
    213168
    214169(define-test (string-lists?)
     
    283238    ))
    284239
    285 
    286 (compound-test (TYPED-LISTS)
     240(define-test (sets?)
     241  (check
     242    ;; argument module
     243    (module nums (type? equ?)
     244      (import scheme)
     245      (define type? number?)
     246      (define equ? =)
     247      )
     248    ;; apply functors
     249    (module num-lists = (typed-lists nums))
     250    (module num-sets = (typed-sets nums num-lists))
     251    ;; import
     252    (import (prefix num-lists num-)
     253            (prefix num-sets num-))
     254    (num-set=
     255      (num-typed-list->set (num-typed-list 1 2 1 3 2 3))
     256      (num-set 3 2 1))
     257    (num-set? (num-set 1 2 3))
     258    (num-set? (num-set 1 2 2 3))
     259    (num-set= (num-set 2 1 3) (num-set 1 2 2 3))
     260    (num-set-in? 2 (num-set 1 1 2 3))
     261    (num-set<= (num-set 2 1 2) (num-set 4 1 2 3 4))
     262    (num-set=
     263      (num-set-add 0 (num-set 1 2 3))
     264      (num-set 0 1 2 3))
     265    (num-set=
     266      (num-set-add 2 (num-set 1 2 3))
     267      (num-set 1 2 3))
     268    (= (num-set-cardinality (num-set 2 1 2 3 2)) 3)
     269    (num-set=
     270      (num-set-remove 2 (num-set 2 1 2 3 2))
     271      (num-set 1 3))
     272    (num-set=
     273      (num-set 0 1 1 0 2 3 2)
     274      (num-set 2 3 0 1))
     275    (num-set=
     276      (num-set-difference (num-set 0 2 1 3) (num-set 1 1))
     277      (num-set 0 2 3))
     278    (num-set=
     279      (num-set-union (num-set 1 2) (num-set 2 3) (num-set 3 4))
     280      (num-set 1 2 3 4))
     281    (num-set=
     282      (num-set-intersection (num-set 1 2 3 4) (num-set 2 3 5) (num-set 3 4))
     283      (num-set 3))
     284    (num-set= (num-set-filter odd? (num-set 2 1 3 3 1 1)) (num-set 3 1))
     285    ))
     286
     287
     288(compound-test (TYPED-LISTS-AND-SETS)
    287289  (number-lists?)
    288290  (any-lists?)
    289   (sets?)
    290291  (string-lists?)
    291292  (symbol-lists?)
    292293  (list-lists?)
    293294  (pair-lists?)
     295  (sets?)
    294296  )
  • release/4/typed-lists/tags/1.3/typed-lists.meta

    r31219 r31264  
    11;;;; typed-lists.meta -*- Scheme -*-
    22
    3 ((synopsis "Immutable typed lists")
     3((synopsis "Immutable typed lists and sets")
    44 (category lang-exts)
    55 (license "BSD")
  • release/4/typed-lists/tags/1.3/typed-lists.scm

    r31238 r31264  
    3636(require-library datatype)
    3737
    38 (functor (typed-lists (M (type? equ?)))
    39   ;;functor exports
     38(define-interface LISTS
    4039  (typed-lists typed-list? typed-list untyped-list->typed-list typed-list->untyped-list
    4140   list-apply list-null list-null? list-cons list-first list-rest list-reverse
     
    4746   list-drop list-drop-while list-take list-take-while list-repeat list-iterate
    4847   list-iterate-while list-iterate-until list-zip list-interpose list-every?
    49    list-some list-not-every? list-not-any? list-in? list-bind
    50    ;sets
    51    sets set? set typed-list->set set->typed-list set-in?  set-cardinality
     48   list-some list-not-every? list-not-any? list-in? list-bind))
     49
     50(define-interface SETS
     51   (sets set? set typed-list->set set->typed-list set-in?  set-cardinality
    5252    set-filter set-null? set-difference set-add set-remove
    53     set= set>= set<= set-union set-intersection)
     53    set= set>= set<= set-union set-intersection))
     54
     55(functor (typed-lists (M (type? equ?))) LISTS
    5456
    5557
     
    628630      ((sym) (assq sym signatures)))))
    629631
     632) ; functor typed-lists
     633
     634(functor (typed-sets (M (type? equ?)) (N LISTS)) SETS
     635
     636(import scheme
     637        (only chicken error define-record-printer
     638              unless receive case-lambda)
     639        (only data-structures list-of? o compose)
     640        (only extras sprintf)
     641        datatype
     642        M N)
     643
    630644;;; sets as typed-lists
    631645
     
    790804      ((sym) (assq sym signatures)))))
    791805
    792 ) ; functor typed-lists
     806) ; functor typed-sets
    793807
    794808;(use simple-tests)
     
    800814;  (define equ? =))
    801815;;; apply functor
    802 ;(module lists = (typed-lists nums))
    803 ;
    804 ;(import lists)
     816;(module num-lists = (typed-lists nums))
     817;(module num-sets = (typed-sets nums num-lists))
     818;(import num-lists num-sets)
    805819;
    806820;(use bindings)
     
    809823;                      (lambda (seq it) (list-item it seq))
    810824;                      (lambda (seq it) (list-drop it seq)))
    811 ;(xpr:val (typed-list? (bind (a b . c) (typed-list 1 2 3 4) c)))
     825;(xpr:val
     826;  (typed-list? (bind (a b . c) (typed-list 1 2 3 4) c))
     827;  (set 1 2 1 4 2 4 3 5)
     828;  )
  • release/4/typed-lists/tags/1.3/typed-lists.setup

    r31238 r31264  
    33(compile -O3 -s -d1 typed-lists.scm -J)
    44(compile -O3 -d0 -s typed-lists.import.scm)
     5(compile -O3 -d0 -s typed-sets.import.scm)
    56
    67(install-extension
    78 'typed-lists
    8  '("typed-lists.so" "typed-lists.import.so")
    9  '((version "1.2")))
     9 '("typed-lists.so" "typed-lists.import.so" "typed-sets.import.so")
     10 '((version "1.3")))
    1011
  • release/4/typed-lists/trunk/tests/run.scm

    r31238 r31264  
    11(require-library cells simple-tests datatype)
    2 (import typed-lists simple-tests datatype)
     2(import typed-lists typed-sets simple-tests datatype)
    33
    44(define-test (number-lists?)
    55  (check
    66    ;; argument module
    7     (module nums (type? equ?)
     7    (module numbers (type? equ?)
    88      (import scheme cells)
    99      (define (type? x)
     
    2020
    2121    ;; apply functor
    22     (module lists = (typed-lists nums))
     22    (module lists = (typed-lists numbers))
    2323   
    2424    ;; import
     
    166166    ))
    167167
    168 (define-test (sets?)
    169   (check
    170 ;    ;; argument module
    171 ;    (module any (type? equ?)
    172 ;      (import scheme)
    173 ;      (define (type? x) #t)
    174 ;      (define (equ? x y) (equal? x y))
    175 ;      )
    176 ;    ;; apply functor
    177 ;    (module any-lists = (typed-lists any))
    178 ;    ;; import
    179 ;    (import any-lists)
    180     (aset=
    181       (atyped-list->set (atyped-list 1 2 1 3 2 3))
    182       (aset 3 2 1))
    183     (aset? (aset 1 2 3))
    184     (aset? (aset 1 2 2 3))
    185     (aset= (aset 2 1 3) (aset 1 2 2 3))
    186     (aset-in? 2 (aset 1 1 2 3))
    187     (aset<= (aset 2 1 2) (aset 4 1 2 3 4))
    188     (aset=
    189       (aset-add 0 (aset 1 2 3))
    190       (aset 0 1 2 3))
    191     (aset=
    192       (aset-add 2 (aset 1 2 3))
    193       (aset 1 2 3))
    194     (= (aset-cardinality (aset 2 1 2 3 2)) 3)
    195     (aset=
    196       (aset-remove 2 (aset 2 1 2 3 2))
    197       (aset 1 3))
    198     (aset=
    199       (aset 0 1 1 0 2 3 2)
    200       (aset 2 3 0 1))
    201     (aset=
    202       (aset-difference (aset 0 2 1 3) (aset 1 1))
    203       (aset 0 2 3))
    204     (aset=
    205       (aset-union (aset 1 2) (aset 2 3) (aset 3 4))
    206       (aset 1 2 3 4))
    207     (aset=
    208       (aset-intersection (aset 1 2 3 4) (aset 2 3 5) (aset 3 4))
    209       (aset 3))
    210     (aset= (aset-filter odd? (aset 2 1 3 3 1 1)) (aset 3 1))
    211     ))
    212 
    213168
    214169(define-test (string-lists?)
     
    283238    ))
    284239
    285 
    286 (compound-test (TYPED-LISTS)
     240(define-test (sets?)
     241  (check
     242    ;; argument module
     243    (module nums (type? equ?)
     244      (import scheme)
     245      (define type? number?)
     246      (define equ? =)
     247      )
     248    ;; apply functors
     249    (module num-lists = (typed-lists nums))
     250    (module num-sets = (typed-sets nums num-lists))
     251    ;; import
     252    (import (prefix num-lists num-)
     253            (prefix num-sets num-))
     254    (num-set=
     255      (num-typed-list->set (num-typed-list 1 2 1 3 2 3))
     256      (num-set 3 2 1))
     257    (num-set? (num-set 1 2 3))
     258    (num-set? (num-set 1 2 2 3))
     259    (num-set= (num-set 2 1 3) (num-set 1 2 2 3))
     260    (num-set-in? 2 (num-set 1 1 2 3))
     261    (num-set<= (num-set 2 1 2) (num-set 4 1 2 3 4))
     262    (num-set=
     263      (num-set-add 0 (num-set 1 2 3))
     264      (num-set 0 1 2 3))
     265    (num-set=
     266      (num-set-add 2 (num-set 1 2 3))
     267      (num-set 1 2 3))
     268    (= (num-set-cardinality (num-set 2 1 2 3 2)) 3)
     269    (num-set=
     270      (num-set-remove 2 (num-set 2 1 2 3 2))
     271      (num-set 1 3))
     272    (num-set=
     273      (num-set 0 1 1 0 2 3 2)
     274      (num-set 2 3 0 1))
     275    (num-set=
     276      (num-set-difference (num-set 0 2 1 3) (num-set 1 1))
     277      (num-set 0 2 3))
     278    (num-set=
     279      (num-set-union (num-set 1 2) (num-set 2 3) (num-set 3 4))
     280      (num-set 1 2 3 4))
     281    (num-set=
     282      (num-set-intersection (num-set 1 2 3 4) (num-set 2 3 5) (num-set 3 4))
     283      (num-set 3))
     284    (num-set= (num-set-filter odd? (num-set 2 1 3 3 1 1)) (num-set 3 1))
     285    ))
     286
     287
     288(compound-test (TYPED-LISTS-AND-SETS)
    287289  (number-lists?)
    288290  (any-lists?)
    289   (sets?)
    290291  (string-lists?)
    291292  (symbol-lists?)
    292293  (list-lists?)
    293294  (pair-lists?)
     295  (sets?)
    294296  )
  • release/4/typed-lists/trunk/typed-lists.meta

    r31219 r31264  
    11;;;; typed-lists.meta -*- Scheme -*-
    22
    3 ((synopsis "Immutable typed lists")
     3((synopsis "Immutable typed lists and sets")
    44 (category lang-exts)
    55 (license "BSD")
  • release/4/typed-lists/trunk/typed-lists.scm

    r31238 r31264  
    3636(require-library datatype)
    3737
    38 (functor (typed-lists (M (type? equ?)))
    39   ;;functor exports
     38(define-interface LISTS
    4039  (typed-lists typed-list? typed-list untyped-list->typed-list typed-list->untyped-list
    4140   list-apply list-null list-null? list-cons list-first list-rest list-reverse
     
    4746   list-drop list-drop-while list-take list-take-while list-repeat list-iterate
    4847   list-iterate-while list-iterate-until list-zip list-interpose list-every?
    49    list-some list-not-every? list-not-any? list-in? list-bind
    50    ;sets
    51    sets set? set typed-list->set set->typed-list set-in?  set-cardinality
     48   list-some list-not-every? list-not-any? list-in? list-bind))
     49
     50(define-interface SETS
     51   (sets set? set typed-list->set set->typed-list set-in?  set-cardinality
    5252    set-filter set-null? set-difference set-add set-remove
    53     set= set>= set<= set-union set-intersection)
     53    set= set>= set<= set-union set-intersection))
     54
     55(functor (typed-lists (M (type? equ?))) LISTS
    5456
    5557
     
    628630      ((sym) (assq sym signatures)))))
    629631
     632) ; functor typed-lists
     633
     634(functor (typed-sets (M (type? equ?)) (N LISTS)) SETS
     635
     636(import scheme
     637        (only chicken error define-record-printer
     638              unless receive case-lambda)
     639        (only data-structures list-of? o compose)
     640        (only extras sprintf)
     641        datatype
     642        M N)
     643
    630644;;; sets as typed-lists
    631645
     
    790804      ((sym) (assq sym signatures)))))
    791805
    792 ) ; functor typed-lists
     806) ; functor typed-sets
    793807
    794808;(use simple-tests)
     
    800814;  (define equ? =))
    801815;;; apply functor
    802 ;(module lists = (typed-lists nums))
    803 ;
    804 ;(import lists)
     816;(module num-lists = (typed-lists nums))
     817;(module num-sets = (typed-sets nums num-lists))
     818;(import num-lists num-sets)
    805819;
    806820;(use bindings)
     
    809823;                      (lambda (seq it) (list-item it seq))
    810824;                      (lambda (seq it) (list-drop it seq)))
    811 ;(xpr:val (typed-list? (bind (a b . c) (typed-list 1 2 3 4) c)))
     825;(xpr:val
     826;  (typed-list? (bind (a b . c) (typed-list 1 2 3 4) c))
     827;  (set 1 2 1 4 2 4 3 5)
     828;  )
  • release/4/typed-lists/trunk/typed-lists.setup

    r31238 r31264  
    33(compile -O3 -s -d1 typed-lists.scm -J)
    44(compile -O3 -d0 -s typed-lists.import.scm)
     5(compile -O3 -d0 -s typed-sets.import.scm)
    56
    67(install-extension
    78 'typed-lists
    8  '("typed-lists.so" "typed-lists.import.so")
    9  '((version "1.2")))
     9 '("typed-lists.so" "typed-lists.import.so" "typed-sets.import.so")
     10 '((version "1.3")))
    1011
Note: See TracChangeset for help on using the changeset viewer.