aboutsummaryrefslogtreecommitdiff
path: root/L-99.lisp
diff options
context:
space:
mode:
authorMasaya Tojo <masaya@tojo.tokyo>2021-08-01 01:14:47 +0900
committerMasaya Tojo <masaya@tojo.tokyo>2021-08-01 02:00:27 +0900
commit5ff4399cdea98a6805568db18581ef176f2aa816 (patch)
tree86f248e1182ffaff2a0ec532a07a39b1b3d60c15 /L-99.lisp
parentbe426f930462ffa7f54a0d775a0c8a6adaf5e3b4 (diff)
L-99: Solve P20 problem.
Diffstat (limited to 'L-99.lisp')
-rw-r--r--L-99.lisp20
1 files changed, 20 insertions, 0 deletions
diff --git a/L-99.lisp b/L-99.lisp
index ff9e1c6..820e741 100644
--- a/L-99.lisp
+++ b/L-99.lisp
@@ -569,3 +569,23 @@
(natp n)
(< n (len x)))
(subsetp x (rotate x n))))
+
+;; P20 (*) Remove the K'th element from a list.
+(defun remove-at (x n)
+ (cond
+ ((endp x) nil)
+ ((zp (1- n)) (cdr x))
+ (t (cons (car x)
+ (remove-at (cdr x) (1- n))))))
+
+(defthm len-remove-at
+ (implies (and (posp i)
+ (<= i (len x)))
+ (equal (len (remove-at x i))
+ (- (len x) 1))))
+
+(defthm not-member-element-at-remove-at-implies-only-one
+ (implies (and (posp i)
+ (<= i (len x))
+ (not (member (element-at x i) (remove-at x i))))
+ (equal (count (element-at x i) x) 1)))