Changeset 31234 in project
 Timestamp:
 08/18/14 13:04:56 (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

wiki/eggref/4/typedlists
r31221 r31234 6 6 7 7 Scheme lists are mutable and untyped. The list types produced with 8 thismodule, a functor, are immutable and typed.8 module, a functor, are immutable and typed. 9 9 10 10 Concerning mutability, Scheme's authors, G. J. Sussman and G. L. Steele jr. … … 523 523 (listnotevery? odd? (typedlist 1 2 3)) 524 524 (listnotany? odd? (typedlist 2 4 6)) 525 (listin? (typedlist 2 3) (typedlist 1 2 3)) 526 (not (listin? (typedlist 1 2 3) (typedlist 2 3))) 527 (not (listin? (typedlist 1 2 3) (typedlist 2 1 3))) 528 (listin? (typedlist) (typedlist 2 3)) 525 529 526 530 ;;; numbersets … … 586 590 (symlistbind () (symlistnull) #t) 587 591 592 ;;; pairlists 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 pairlists = (typedlists pairs)) 603 604 ;; tests 605 (import (prefix pairlists nsp)) 606 (define nspl (nsptypedlist (cons 1 "one") (cons 2 "two") (cons 3 "three"))) 607 (equal? (nsplistassoc 2 nspl) '(2 . "two")) 608 (not (nsplistassp zero? nspl)) 588 609 </enscript> 589 610 … … 594 615 == Last update 595 616 596 Aug 1 7, 2014617 Aug 18, 2014 597 618 598 619 == Author … … 633 654 == Version History 634 655 656 ; 1.1 : listbind corrected, listin? added 635 657 ; 1.0 : functor implementation 636 658 ; 0.1 : initial import
Note: See TracChangeset
for help on using the changeset viewer.