+
+(define member (lexpr (obj list test?)
+ (cond ((null? list)
+ #f
+ )
+ (else
+ (if (null? test?) (set! test? equal?) (set! test? (car test?)))
+ (if (test? obj (car list))
+ list
+ (member obj (cdr list) test?))
+ )
+ )
+ )
+ )
+
+(member '(2) '((1) (2) (3)))
+
+(member '(4) '((1) (2) (3)))
+
+(define (memq obj list) (member obj list eq?))
+
+(memq 2 '(1 2 3))
+
+(memq 4 '(1 2 3))
+
+(memq '(2) '((1) (2) (3)))
+
+(define (memv obj list) (member obj list eqv?))
+
+(memv 2 '(1 2 3))
+
+(memv 4 '(1 2 3))
+
+(memv '(2) '((1) (2) (3)))
+
+(define (_assoc obj list test?)
+ (if (null? list)
+ #f
+ (if (test? obj (caar list))
+ (car list)
+ (_assoc obj (cdr list) test?)
+ )
+ )
+ )
+
+(define (assq obj list) (_assoc obj list eq?))
+(define (assv obj list) (_assoc obj list eqv?))
+(define (assoc obj list) (_assoc obj list equal?))
+
+(assq 'a '((a 1) (b 2) (c 3)))
+(assv 'b '((a 1) (b 2) (c 3)))
+(assoc '(c) '((a 1) (b 2) ((c) 3)))
+
+(define char? integer?)
+
+(char? #\q)
+(char? "h")
+
+(define (char-upper-case? c) (<= #\A c #\Z))
+
+(char-upper-case? #\a)
+(char-upper-case? #\B)
+(char-upper-case? #\0)
+(char-upper-case? #\space)
+
+(define (char-lower-case? c) (<= #\a c #\a))
+
+(char-lower-case? #\a)
+(char-lower-case? #\B)
+(char-lower-case? #\0)
+(char-lower-case? #\space)
+
+(define (char-alphabetic? c) (or (char-upper-case? c) (char-lower-case? c)))
+
+(char-alphabetic? #\a)
+(char-alphabetic? #\B)
+(char-alphabetic? #\0)
+(char-alphabetic? #\space)
+
+(define (char-numeric? c) (<= #\0 c #\9))
+
+(char-numeric? #\a)
+(char-numeric? #\B)
+(char-numeric? #\0)
+(char-numeric? #\space)
+
+(define (char-whitespace? c) (or (<= #\tab c #\return) (= #\space c)))
+
+(char-whitespace? #\a)
+(char-whitespace? #\B)
+(char-whitespace? #\0)
+(char-whitespace? #\space)
+
+(define (char->integer c) c)
+(define (integer->char c) char-integer)
+
+(define (char-upcase c) (if (char-lower-case? c) (+ c (- #\A #\a)) c))
+
+(char-upcase #\a)
+(char-upcase #\B)
+(char-upcase #\0)
+(char-upcase #\space)
+
+(define (char-downcase c) (if (char-upper-case? c) (+ c (- #\a #\A)) c))
+
+(char-downcase #\a)
+(char-downcase #\B)
+(char-downcase #\0)
+(char-downcase #\space)
+
+(define string (lexpr (chars) (list->string chars)))
+
+(display "apply\n")
+(apply cons '(a b))
+
+(define map (lexpr (proc lists)
+ (let* ((args (lambda (lists)
+ (if (null? lists) ()
+ (cons (caar lists) (args (cdr lists))))))
+ (next (lambda (lists)
+ (if (null? lists) ()
+ (cons (cdr (car lists)) (next (cdr lists))))))
+ (domap (lambda (lists)
+ (if (null? (car lists)) ()
+ (cons (apply proc (args lists)) (domap (next lists)))
+ )))
+ )
+ (domap lists))))
+
+(map cadr '((a b) (d e) (g h)))
+
+(define for-each (lexpr (proc lists)
+ (apply map proc lists)
+ #t))
+
+(for-each display '("hello" " " "world" "\n"))
+
+(define _string-ml (lambda (strings)
+ (if (null? strings) ()
+ (cons (string->list (car strings)) (_string-ml (cdr strings))))))
+
+(define string-map (lexpr (proc strings)
+ (list->string (apply map proc (_string-ml strings))))))
+
+(string-map (lambda (x) (+ 1 x)) "HAL")
+
+(define string-for-each (lexpr (proc strings)
+ (apply for-each proc (_string-ml strings))))
+
+(string-for-each write-char "IBM\n")
+
+(define newline (lambda () (write-char #\newline)))
+
+(newline)
+
+(call-with-current-continuation
+ (lambda (exit)
+ (for-each (lambda (x)
+ (write "test" x)
+ (if (negative? x)
+ (exit x)))
+ '(54 0 37 -3 245 19))
+ #t))
+
+
+ ; `q -> (quote q)
+ ; `(q) -> (append (quote (q)))
+ ; `(a ,(+ 1 2)) -> (append (quote (a)) (list (+ 1 2)))
+ ; `(a ,@(list 1 2 3) -> (append (quote (a)) (list 1 2 3))
+
+
+
+`(hello ,(+ 1 2) ,@(list 1 2 3) `foo)
+
+(define repeat (macro (count rest)
+ `(let ((__count__ ,count))
+ (while (<= 0 (set! __count__ (- __count__ 1))) ,@rest))))
+
+(repeat 2 (write 'hello))
+(repeat 3 (write 'goodbye))
+
+(define case (macro (test l)
+ (let* ((_unarrow
+ ; construct the body of the
+ ; case, dealing with the
+ ; lambda version ( => lambda)
+
+ (lambda (l)
+ (cond ((null? l) l)
+ ((eq? (car l) '=>) `(( ,(cadr l) __key__)))
+ (else l))))
+ (_case (lambda (l)
+
+ ; Build the case elements, which is
+ ; simply a list of cond clauses
+
+ (cond ((null? l) ())
+
+ ; else case
+
+ ((eq? (caar l) 'else)
+ `((else ,@(_unarrow (cdr (car l))))))
+
+ ; regular case
+
+ (else
+ (cons
+ `((eqv? ,(caar l) __key__)
+ ,@(_unarrow (cdr (car l))))
+ (_case (cdr l)))
+ )
+ ))))
+
+ ; now construct the overall
+ ; expression, using a lambda
+ ; to hold the computed value
+ ; of the test expression
+
+ `((lambda (__key__)
+ (cond ,@(_case l))) ,test))))
+
+(case 12 (1 "one") (2 "two") (3 => (lambda (x) (write "the value is" x))) (12 "twelve") (else "else"))
+
+;(define number->string (lexpr (arg opt)
+; (let ((base (if (null? opt) 10 (car opt)))
+ ;
+;
+