; expressions to evaluate
(set! make-exprs (lambda (vars exprs)
- (cond ((not (null? vars)) (cons
- (list set
- (list quote
- (car (car vars))
- )
- (cadr (car vars))
- )
- (make-exprs (cdr vars) exprs)
- )
- )
+ (cond ((not (null? vars))
+ (cons
+ (list set
+ (list quote
+ (car (car vars))
+ )
+ (cond ((null? (cdr (car vars))) ())
+ (else (cadr (car vars))))
+ )
+ (make-exprs (cdr vars) exprs)
+ )
+ )
(exprs)
)
)
(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 1+ "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))
+
;(define number->string (lexpr (arg opt)
; (let ((base (if (null? opt) 10 (car opt)))
;