| list-put | ||
|---|---|---|
| Prev | Next | |
(list-put vlist ordinal value #!optional (span 1))
Replaces the ordinalth value of vlist with value. If span > 1, replaces ordinal to ordinal+span-1 values starting at ordinal.
(list-put (1 2 3 4 5) 2 0 2) returns (1 0 0 4 5).
Norman Walsh, <ndw@nwalsh.com>
(define (list-put vlist ordinal value #!optional (span 1))
;; Replace a specific member of a list
(let loop ((result vlist) (count span) (k ordinal))
(if (equal? count 0)
result
(let ((head (list-head result (- k 1)))
(tail (list-tail result k)))
(loop (append head (list value) tail) (- count 1) (+ k 1))))))| Prev | Home | Next |
| list-member-find | Up | map |