Changeset 31234 in project


Ignore:
Timestamp:
08/18/14 13:04:56 (5 years ago)
Author:
juergen
Message:

typed-lists 1.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/typed-lists

    r31221 r31234  
    66
    77Scheme lists are mutable and untyped. The list types produced with
    8 this module, a functor, are immutable and typed.
     8module, a functor, are immutable and typed.
    99
    1010Concerning mutability, Scheme's authors, G. J. Sussman and G. L. Steele jr.
     
    523523(list-not-every? odd? (typed-list 1 2 3))
    524524(list-not-any? odd? (typed-list 2 4 6))
     525(list-in? (typed-list 2 3) (typed-list 1 2 3))
     526(not (list-in? (typed-list 1 2 3) (typed-list 2 3)))
     527(not (list-in? (typed-list 1 2 3) (typed-list 2 1 3)))
     528(list-in? (typed-list) (typed-list 2 3))
    525529
    526530;;; number-sets
     
    586590(sym-list-bind () (sym-list-null) #t)
    587591
     592;;; pair-lists
     593;;; ----------
     594;; argument module
     595(module pairs (type? equ?)
     596  (import scheme)
     597  (define (type? x)
     598    (and (pair? x) (number? (car x)) (string? (cdr x))))
     599  (define equ? equal?))
     600
     601;; apply functor
     602(module pair-lists = (typed-lists pairs))
     603
     604;; tests
     605(import (prefix pair-lists nsp-))
     606(define nspl (nsp-typed-list (cons 1 "one") (cons 2 "two") (cons 3 "three")))
     607(equal? (nsp-list-assoc 2 nspl) '(2 . "two"))
     608(not (nsp-list-assp zero? nspl))
    588609</enscript>
    589610
     
    594615== Last update
    595616
    596 Aug 17, 2014
     617Aug 18, 2014
    597618
    598619== Author
     
    633654== Version History
    634655
     656; 1.1 : list-bind corrected, list-in? added
    635657; 1.0 : functor implementation
    636658; 0.1 : initial import
Note: See TracChangeset for help on using the changeset viewer.