From ce9061b7ce8594924f3456a68a234833d5ce3080 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 25 Mar 2015 09:56:24 -0400 Subject: [PATCH] Added (list-set!) --- TODO | 3 --- trans.scm | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index a7e6679f..4170fa2a 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,5 @@ Working TODO list: - - Add (list-set!) from r7rs - will likely require tweaks to GC similar to (set-car! / set-cdr!) - - 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. diff --git a/trans.scm b/trans.scm index 0c209539..859e3da6 100644 --- a/trans.scm +++ b/trans.scm @@ -117,6 +117,9 @@ lst (list-tail (cdr lst) (- k 1)))) (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 (symbol=? sym1 sym2 . syms) (and