Avoid let* in scm.mes.

* module/mes/scm.mes (case, max, min): Avoid let*.
This commit is contained in:
Jan Nieuwenhuizen 2016-10-21 10:52:59 +02:00
parent 37d27f66e3
commit 2926190567

View file

@ -31,18 +31,16 @@
(define (list . rest) rest) (define (list . rest) rest)
(define-macro (case val . args) (define-macro (case val . args)
(if (null? args) (if (null? args) #f
#f (let ((clause (car args)))
(let* ((clause (car args)) (let ((pred (car clause)))
(pred (car clause)) (let ((body (cdr clause)))
(body (cdr clause))) (if (pair? pred) `(if ,(if (null? (cdr pred))
(if (pair? pred) `(eq? ,val ',(car pred))
`(if ,(if (null? (cdr pred)) `(member ,val ',pred))
`(eq? ,val ',(car pred)) (begin ,@body)
`(member ,val ',pred)) (case ,val ,@(cdr args)))
(begin ,@body) `(begin ,@body)))))))
(case ,val ,@(cdr args)))
`(begin ,@body)))))
(define-macro (when expr . body) (define-macro (when expr . body)
`(if ,expr `(if ,expr
@ -139,15 +137,15 @@
(define (max x . rest) (define (max x . rest)
(if (null? rest) x (if (null? rest) x
(let* ((y (car rest)) (let ((y (car rest)))
(z (if (> x y) x y))) (let ((z (if (> x y) x y)))
(apply max (cons z (cdr rest)))))) (apply max (cons z (cdr rest)))))))
(define (min x . rest) (define (min x . rest)
(if (null? rest) x (if (null? rest) x
(let* ((y (car rest)) (let ((y (car rest)))
(z (if (< x y) x y))) (let ((z (if (< x y) x y)))
(apply min (cons z (cdr rest)))))) (apply min (cons z (cdr rest)))))))
(define gensym (define gensym
(let ((counter 0)) (let ((counter 0))