feat: add List.remove-nth (#1277)

This commit is contained in:
Veit Heller 2021-07-13 17:54:15 +02:00 committed by GitHub
parent fb1ee66ecc
commit 092b249ac7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -329,6 +329,13 @@ elements is uneven, the trailing element will be discarded.")
(= n 0) (car l)
(List.nth (cdr l) (dec n))))
(doc remove-nth "removes the nth element from the list `l`.")
(defndynamic remove-nth [l n]
(cond
(empty? l) '()
(= n 0) (cdr l)
(cons (car l) (List.remove-nth (cdr l) (dec n)))))
(doc update-nth "updates the nth element of the list `l` using the function `f`.")
(defndynamic update-nth [l n f]
(cond