mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 01:00:20 +02:00
(append-map, append-map!): Rewrite as simple "apply append" forms, for
tail recursiveness.
This commit is contained in:
parent
890ed2790b
commit
66f0ff4ab9
1 changed files with 3 additions and 20 deletions
|
@ -674,27 +674,10 @@
|
|||
|
||||
|
||||
(define (append-map f clist1 . rest)
|
||||
(if (null? rest)
|
||||
(let lp ((l clist1))
|
||||
(if (null? l)
|
||||
'()
|
||||
(append (f (car l)) (lp (cdr l)))))
|
||||
(let lp ((l (cons clist1 rest)))
|
||||
(if (any1 null? l)
|
||||
'()
|
||||
(append (apply f (map1 car l)) (lp (map1 cdr l)))))))
|
||||
|
||||
(apply append (apply map f clist1 rest)))
|
||||
|
||||
(define (append-map! f clist1 . rest)
|
||||
(if (null? rest)
|
||||
(let lp ((l clist1))
|
||||
(if (null? l)
|
||||
'()
|
||||
(append! (f (car l)) (lp (cdr l)))))
|
||||
(let lp ((l (cons clist1 rest)))
|
||||
(if (any1 null? l)
|
||||
'()
|
||||
(append! (apply f (map1 car l)) (lp (map1 cdr l)))))))
|
||||
(apply append! (apply map f clist1 rest)))
|
||||
|
||||
(define (map! f list1 . rest)
|
||||
(if (null? rest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue