summaryrefslogtreecommitdiff
path: root/module/srfi/srfi-1.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2014-03-30 22:28:07 +0200
committerAndy Wingo <wingo@pobox.com>2014-03-31 18:21:04 +0200
commit4926024cfbd9d0a428880a919b6e5a394b4a304d (patch)
tree46cc428574e55a9ac6c6333d0652485015acac1e /module/srfi/srfi-1.scm
parentde3cbadcc08f7f46bab0d91d4dcc5bac2f64613f (diff)
downloadguile-4926024cfbd9d0a428880a919b6e5a394b4a304d.tar.gz
Simplify boot-9 and srfi-1 map
* module/ice-9/boot-9.scm (map): * module/srfi/srfi-1.scm (map): Simplify the implementations to check for list? beforehand. It's faster, and it will be needed if we decide to go recursive.
Diffstat (limited to 'module/srfi/srfi-1.scm')
-rw-r--r--module/srfi/srfi-1.scm19
1 files changed, 5 insertions, 14 deletions
diff --git a/module/srfi/srfi-1.scm b/module/srfi/srfi-1.scm
index c7c1f8dee..919d51274 100644
--- a/module/srfi/srfi-1.scm
+++ b/module/srfi/srfi-1.scm
@@ -566,20 +566,11 @@ has just one element then that's the return value."
(case-lambda
((f l)
(check-arg procedure? f map)
- (let map1 ((hare l) (tortoise l) (move? #f) (out '()))
- (if (pair? hare)
- (if move?
- (if (eq? tortoise hare)
- (scm-error 'wrong-type-arg "map" "Circular list: ~S"
- (list l) #f)
- (map1 (cdr hare) (cdr tortoise) #f
- (cons (f (car hare)) out)))
- (map1 (cdr hare) tortoise #t
- (cons (f (car hare)) out)))
- (if (null? hare)
- (reverse! out)
- (scm-error 'wrong-type-arg "map" "Not a list: ~S"
- (list l) #f)))))
+ (check-arg list? l map)
+ (let map1 ((in l) (out '()))
+ (if (pair? in)
+ (map1 (cdr in) (cons (f (car in)) out))
+ (reverse! out))))
((f l1 . rest)
(check-arg procedure? f map)