We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ad98336 commit fee87e0Copy full SHA for fee87e0
1 file changed
otus-02/src/otus_02/homework/palindrome.clj
@@ -1,6 +1,23 @@
1
(ns otus-02.homework.palindrome
2
(:require [clojure.string :as string]))
3
4
+(defn transform-string [s]
5
+ (-> s
6
+ (string/replace #"[,.-:;!?\"' ]" "")
7
+ (string/lower-case)))
8
-(defn is-palindrome [test-string])
9
+(defn recur-palindrom [test-vec]
10
+ (let [go-next (= (get test-vec 0) (get test-vec (dec (count test-vec))))]
11
+ (cond
12
+ (empty? test-vec) true
13
+ (== (count test-vec) 1) true
14
+ (not go-next) false
15
+ :else (recur-palindrom (subvec test-vec 1 (dec (count test-vec)))))))
16
17
+(defn is-palindrome [test-string]
18
+ (let [s (transform-string test-string)
19
+ s-vec (vec s)]
20
+ (recur-palindrom s-vec)))
21
+
22
+(comment
23
+ (is-palindrome "Civ, ic!"))
0 commit comments