If I have a 开发者_运维问答list of 0's, how would I modify, for example, the 16th 0 in the list?
You have to write it yourself. It is not built in to Scheme because it's not idiomatic and it can be built easily from set-car!
.
(define (list-set! l k obj)
(cond
((or (< k 0) (null? l)) #f)
((= k 0) (set-car! l obj))
(else (list-set! (cdr l) (- k 1) obj))))
If you are doing this a lot, you should probably look at using vectors and vector-set!
instead.
精彩评论