added mappend\!
svn: r8326 original commit: 6267a1912236745a97366e122de2779282eb1c22
This commit is contained in:
parent
61121abe07
commit
317205cbed
|
@ -6,6 +6,7 @@
|
|||
mlist?
|
||||
mlength
|
||||
mappend
|
||||
mappend!
|
||||
mreverse
|
||||
mlist-tail
|
||||
mlist-ref
|
||||
|
@ -95,6 +96,19 @@
|
|||
(mcons (mcar a) (loop (mcdr a)))))]
|
||||
[(a . l) (mappend a (apply mappend l))]))
|
||||
|
||||
;; mappend! : like append, but mutate each list to refer to the next.
|
||||
;; modeled loosely on the v372 behavior
|
||||
|
||||
(define mappend!
|
||||
(case-lambda
|
||||
[() null]
|
||||
[(a) a]
|
||||
[(a b) (let loop ([atail a])
|
||||
(cond [(null? atail) b]
|
||||
[(null? (mcdr atail)) (set-mcdr! atail b) a]
|
||||
[else (loop (mcdr atail))]))]
|
||||
[(a . l) (mappend! a (apply mappend! l))]))
|
||||
|
||||
(define (mreverse l)
|
||||
(let loop ([l l][a null])
|
||||
(cond
|
||||
|
|
Loading…
Reference in New Issue
Block a user