Skip to content

Instantly share code, notes, and snippets.

@beoliver
Last active August 29, 2015 14:20
Show Gist options
  • Save beoliver/754b8d42eed03df848e9 to your computer and use it in GitHub Desktop.
Save beoliver/754b8d42eed03df848e9 to your computer and use it in GitHub Desktop.
Scheme set-nth!
(require r5rs)
(define (set-nth! n xs x)
(cond ((null? xs) (error "index out of bounds"))
((eq? n 0) (set-car! xs x))
(#t (set-nth! (- n 1) (cdr xs) x))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment