summaryrefslogtreecommitdiff
path: root/srfi/srfi-1.scm
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2004-12-05 21:44:18 +0000
committerKevin Ryde <user42@zip.com.au>2004-12-05 21:44:18 +0000
commitaa0745cc05f4a0e89571295a2566d06279d0a99d (patch)
treebbf5f3c48a324aed249792251cde8e1264f7bfcb /srfi/srfi-1.scm
parentb8024707475ea3ae5b4017363dfc2a137318ecd7 (diff)
downloadguile-aa0745cc05f4a0e89571295a2566d06279d0a99d.tar.gz
(alist-copy): Change to a tail-recursive form.
Diffstat (limited to 'srfi/srfi-1.scm')
-rw-r--r--srfi/srfi-1.scm7
1 files changed, 4 insertions, 3 deletions
diff --git a/srfi/srfi-1.scm b/srfi/srfi-1.scm
index 2ebe705f5..96042d6e6 100644
--- a/srfi/srfi-1.scm
+++ b/srfi/srfi-1.scm
@@ -699,10 +699,11 @@
(acons key datum alist))
(define (alist-copy alist)
- (let lp ((a alist))
+ (let lp ((a alist)
+ (rl '()))
(if (null? a)
- '()
- (acons (caar a) (cdar a) (lp (cdr a))))))
+ (reverse! rl)
+ (lp (cdr a) (acons (caar a) (cdar a) rl)))))
(define (alist-delete key alist . rest)
(let ((k= (if (pair? rest) (car rest) equal?)))