Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Palindrome-detection/ACL2/palindrome-detection.acl2
Normal file
17
Task/Palindrome-detection/ACL2/palindrome-detection.acl2
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
(defun reverse-split-at-r (xs i ys)
|
||||
(if (zp i)
|
||||
(mv xs ys)
|
||||
(reverse-split-at-r (rest xs) (1- i)
|
||||
(cons (first xs) ys))))
|
||||
|
||||
(defun reverse-split-at (xs i)
|
||||
(reverse-split-at-r xs i nil))
|
||||
|
||||
(defun is-palindrome (str)
|
||||
(let* ((lngth (length str))
|
||||
(idx (floor lngth 2)))
|
||||
(mv-let (xs ys)
|
||||
(reverse-split-at (coerce str 'list) idx)
|
||||
(if (= (mod lngth 2) 1)
|
||||
(equal (rest xs) ys)
|
||||
(equal xs ys)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue