mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 06:39:17 +02:00
Fixing list-copy for improper lists.
This commit is contained in:
parent
ddfdd04a8f
commit
b27143a96c
1 changed files with 4 additions and 1 deletions
|
@ -150,7 +150,10 @@
|
|||
(if (>= i n) res (lp (+ i 1) (cons init res))))))
|
||||
|
||||
(define (list-copy ls)
|
||||
(reverse (reverse ls)))
|
||||
(let lp ((ls ls) (res '()))
|
||||
(if (pair? ls)
|
||||
(lp (cdr ls) (cons (car ls) res))
|
||||
(append (reverse res) ls))))
|
||||
|
||||
(define (list-set! ls k x)
|
||||
(cond ((null? ls) (error "invalid list index"))
|
||||
|
|
Loading…
Add table
Reference in a new issue