diff --git a/module/mes/base.mes b/module/mes/base.mes index 704ea566..51d0f488 100644 --- a/module/mes/base.mes +++ b/module/mes/base.mes @@ -107,13 +107,13 @@ ((closure? p) #t) (#t #f))) -(define (map f l . r) - (if (null? l) '() - (if (null? r) (cons (f (car l)) (map f (cdr l))) - (if (null? (cdr r)) - (cons (f (car l) (caar r)) (map f (cdr l) (cdar r))) - (if (null? (cddr r)) - (cons (f (car l) (caar r) (caadr r)) (map f (cdr l) (cdar r) (cdadr r))) - (if (null? (cdddr r)) - (cons (f (car l) (caar r) (caadr r) (car (caddr r))) (map f (cdr l) (cdar r) (cdadr r) (cdr (caddr r)))) - (error 'unsupported (cons* "map 5:" f l r))) ))))) +(define (map f h . t) + (if (null? h) '() + (if (null? t) (cons (f (car h)) (map f (cdr h))) + (if (null? (cdr t)) + (cons (f (car h) (caar t)) (map f (cdr h) (cdar t))) + (if (null? (cddr t)) + (cons (f (car h) (caar t) (caadr t)) (map f (cdr h) (cdar t) (cdadr t))) + (if (null? (cdddr t)) + (cons (f (car h) (caar t) (caadr t) (car (caddr t))) (map f (cdr h) (cdar t) (cdadr t) (cdr (caddr t)))) + (error 'unsupported (cons* "map 5:" f h t))) ))))) diff --git a/module/srfi/srfi-1.mes b/module/srfi/srfi-1.mes index 321a47f5..d5103390 100644 --- a/module/srfi/srfi-1.mes +++ b/module/srfi/srfi-1.mes @@ -40,11 +40,17 @@ (define (append-map f lst . rest) (apply append (apply map f (cons lst rest)))) -(define (filter-map f lst) - (if (null? lst) (list) - (let ((r (f (car lst)))) - (if r (cons r (filter-map f (cdr lst))) - (filter-map f (cdr lst)))))) +(define (filter-map f h . t) + (if (null? h) '() + (if (null? t) + (let ((r (f (car h)))) + (if r (cons r (filter-map f (cdr h))) + (filter-map f (cdr h)))) + (if (null? (cdr t)) + (let ((r (f (car h) (caar t)))) + (if r (cons r (filter-map f (cdr h) (cdar t))) + (filter-map f (cdr h) (cdar t)))) + (error 'unsupported (cons* "filter-map 3:" f h t)))))) ;;; nyacc requirements