diff options
author | Masaya Tojo <masaya@tojo.tokyo> | 2021-08-01 01:14:47 +0900 |
---|---|---|
committer | Masaya Tojo <masaya@tojo.tokyo> | 2021-08-01 02:00:27 +0900 |
commit | 5ff4399cdea98a6805568db18581ef176f2aa816 (patch) | |
tree | 86f248e1182ffaff2a0ec532a07a39b1b3d60c15 | |
parent | be426f930462ffa7f54a0d775a0c8a6adaf5e3b4 (diff) |
L-99: Solve P20 problem.
-rw-r--r-- | L-99.lisp | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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))) |