summaryrefslogtreecommitdiff
path: root/lists/remove-nth.lisp
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2022-07-16 15:34:00 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2022-07-16 15:34:00 +0900
commit8ada9230a681e8c1ee23686815c866d6eebde7e8 (patch)
tree6fd812d2b2f896cb2c71dfbbddcb4b830d751499 /lists/remove-nth.lisp
parent3ebc1d21bf5fe94ada90a812bbc7879f7a21719f (diff)
lists: remove-nth, shuffle: Add remove-nth and shuffle.
Diffstat (limited to 'lists/remove-nth.lisp')
-rw-r--r--lists/remove-nth.lisp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lists/remove-nth.lisp b/lists/remove-nth.lisp
new file mode 100644
index 0000000..8c62e9d
--- /dev/null
+++ b/lists/remove-nth.lisp
@@ -0,0 +1,20 @@
+(in-package "ACL2")
+
+(defun remove-nth (i x)
+ (declare (xargs :guard (and (natp i)
+ (true-listp x))))
+ (cond ((endp x) nil)
+ ((zp i) (cdr x))
+ (t
+ (cons (car x)
+ (remove-nth (1- i) (cdr x))))))
+
+(defthm len-remove-nth
+ (implies (and (consp x)
+ (< i (len x)))
+ (equal (len (remove-nth i x))
+ (- (len x) 1))))
+
+(defthm true-listp-remove-nth
+ (implies (true-listp x)
+ (true-listp (remove-nth i x))))