From de2e9502cfd25abb44e4b70183a443cc9c9dcd2f Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 9 Jul 2016 22:05:07 +0200 Subject: [PATCH] map: support two lists. --- scm.mes | 4 +++- test.mes | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/scm.mes b/scm.mes index 4109ff27..d816e328 100755 --- a/scm.mes +++ b/scm.mes @@ -95,4 +95,6 @@ EOF (define (map f l . r) (cond ((null l) '()) - ((null r) (cons (f (car l)) (map f (cdr l)))))) + ((null r) (cons (f (car l)) (map f (cdr l)))) + ((null (cdr r)) + (cons (f (car l) (caar r)) (map f (cdr l) (cdar r)))))) diff --git a/test.mes b/test.mes index 98277c3c..43112e28 100644 --- a/test.mes +++ b/test.mes @@ -102,4 +102,8 @@ (newline) (map '(lambda (x) (display x) (newline)) '(5 6 7 8)) (newline) + +(map '(lambda (i a) (display i) (display ':) (display a) (newline)) '(1 2 3 4) '(a b c d)) +(newline) + '()