Added (list-set!)

This commit is contained in:
Justin Ethier 2015-03-25 09:56:24 -04:00
parent d722800131
commit ce9061b7ce
2 changed files with 3 additions and 3 deletions

3
TODO
View file

@ -1,8 +1,5 @@
Working TODO list: Working TODO list:
- Add (list-set!) from r7rs
will likely require tweaks to GC similar to (set-car! / set-cdr!)
- Error handling - Error handling
need to perform much more error handling of input code. one of the biggest is to report if a function is passed the wrong number of arguments, as this will result in segfauls, bad transport errors, etc downstream if it is allowed. need to perform much more error handling of input code. one of the biggest is to report if a function is passed the wrong number of arguments, as this will result in segfauls, bad transport errors, etc downstream if it is allowed.

View file

@ -117,6 +117,9 @@
lst lst
(list-tail (cdr lst) (- k 1)))) (list-tail (cdr lst) (- k 1))))
(define (list-ref lst k) (car (list-tail lst k))) (define (list-ref lst k) (car (list-tail lst k)))
(define (list-set! lst k obj)
(let ((kth (list-tail lst k)))
(set-car! kth obj)))
(define (reverse lst) (foldl cons '() lst)) (define (reverse lst) (foldl cons '() lst))
(define (symbol=? sym1 sym2 . syms) (define (symbol=? sym1 sym2 . syms)
(and (and