Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
5
Task/String-comparison/Clojure/string-comparison-1.clj
Normal file
5
Task/String-comparison/Clojure/string-comparison-1.clj
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(= "abc" "def") ; false
|
||||
(= "abc" "abc") ; true
|
||||
|
||||
(not= "abc" "def") ; true
|
||||
(not= "abc" "abc") ; false
|
||||
2
Task/String-comparison/Clojure/string-comparison-2.clj
Normal file
2
Task/String-comparison/Clojure/string-comparison-2.clj
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(= "abc" "abc" "abc" "abc") ; true
|
||||
(= "abc" "abc" "abc" "def") ; false
|
||||
1
Task/String-comparison/Clojure/string-comparison-3.clj
Normal file
1
Task/String-comparison/Clojure/string-comparison-3.clj
Normal file
|
|
@ -0,0 +1 @@
|
|||
(apply = ["abc" "abc" "abc" "abc"]) ; true
|
||||
14
Task/String-comparison/Clojure/string-comparison-4.clj
Normal file
14
Task/String-comparison/Clojure/string-comparison-4.clj
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(defn str-before [a b]
|
||||
(neg? (compare a b)))
|
||||
|
||||
(defn str-after [a b]
|
||||
(pos? (compare a b)))
|
||||
|
||||
(str-before "abc" "def") ; true
|
||||
(str-before "def" "abc") ; false
|
||||
(str-before "abc" "abc") ; false
|
||||
|
||||
(str-after "abc" "def") ; false
|
||||
(str-after "def" "abc") ; false
|
||||
|
||||
(sort ["foo" "bar" "baz"]) ; ("bar" "baz" "foo")
|
||||
5
Task/String-comparison/Clojure/string-comparison-5.clj
Normal file
5
Task/String-comparison/Clojure/string-comparison-5.clj
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
(defn str-caseless= [a b]
|
||||
(= (clojure.string/lower-case a)
|
||||
(clojure.string/lower-case b)))
|
||||
|
||||
(str-caseless= "foo" "fOO") ; true
|
||||
12
Task/String-comparison/Clojure/string-comparison-6.clj
Normal file
12
Task/String-comparison/Clojure/string-comparison-6.clj
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(defn str-fuzzy= [a b]
|
||||
(let [cook (fn [v] (clojure.string/trim (str v)))]
|
||||
(= (cook a) (cook b))))
|
||||
|
||||
(str-fuzzy= "abc" " abc") ; true
|
||||
(str-fuzzy= "abc" "abc ") ; true
|
||||
(str-fuzzy= "abc" " abc ") ; true
|
||||
|
||||
(str-fuzzy= " 42 " 42) ; true
|
||||
(str-fuzzy= " 42 " (* 6 7)) ; true
|
||||
|
||||
(str-fuzzy= " 2.5" (/ 5.0 2)) ; true
|
||||
8
Task/String-comparison/Clojure/string-comparison-7.clj
Normal file
8
Task/String-comparison/Clojure/string-comparison-7.clj
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(def s1 (str "abc" "def"))
|
||||
(def s2 (str "ab" "cdef"))
|
||||
|
||||
(= s1 "abcdef") ; true
|
||||
(= s1 s2) ; true
|
||||
|
||||
(identical? s1 "abcdef") ; false
|
||||
(identical? s1 s2) ; false
|
||||
8
Task/String-comparison/Clojure/string-comparison-8.clj
Normal file
8
Task/String-comparison/Clojure/string-comparison-8.clj
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(defn istr [s]
|
||||
(.intern s))
|
||||
|
||||
(def s3 (istr s1))
|
||||
(def s4 (istr s2))
|
||||
|
||||
(= s3 s4) ; true
|
||||
(identical? s3 s4) ; true
|
||||
Loading…
Add table
Add a link
Reference in a new issue