mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-28 16:00:22 +02:00
(map!): Define as an alias for map, previous definition was not tail-recursive.
This commit is contained in:
parent
110348aee9
commit
c6424115fe
1 changed files with 2 additions and 16 deletions
|
@ -553,22 +553,8 @@
|
|||
'()
|
||||
(append! (apply f (map1 car l)) (lp (map1 cdr l)))))))
|
||||
|
||||
(define (map! f list1 . rest)
|
||||
(if (null? rest)
|
||||
(let lp ((l list1))
|
||||
(if (null? l)
|
||||
'()
|
||||
(begin
|
||||
(set-car! l (f (car l)))
|
||||
(set-cdr! l (lp (cdr l)))
|
||||
l)))
|
||||
(let lp ((l (cons list1 rest)) (res list1))
|
||||
(if (any1 null? l)
|
||||
'()
|
||||
(begin
|
||||
(set-car! res (apply f (map1 car l)))
|
||||
(set-cdr! res (lp (map1 cdr l) (cdr res)))
|
||||
res)))))
|
||||
;; OPTIMIZE-ME: Re-use cons cells of list1
|
||||
(define map! map)
|
||||
|
||||
(define (pair-for-each f clist1 . rest)
|
||||
(if (null? rest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue