-
-
Save practicalli-johnny/2037502 to your computer and use it in GitHub Desktop.
Ldnclj dojo - Palindrome detector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns clojuredojo.core) | |
(defn palindrome-detector [thing] (= (reverse thing) (seq thing)) ) | |
(def __ palindrome-detector) | |
(false? (__ '(1 2 3 4 5))) | |
(true? (__ "racecar")) | |
(true? (__ [:foo :bar :foo])) | |
(true? (__ '(1 1 3 3 1 1))) | |
(false? (__ '(:a :b :c))) | |
(defn something [x] (remove coll? (tree-seq coll? vec x))) | |
(def __ something) | |
(= (__ '((1 2) 3 [4 [5 6]])) '(1 2 3 4 5 6)) | |
(= (__ ["a" ["b"] "c"]) '("a" "b" "c")) | |
(= (__ '((((:a))))) '(:a)) | |
(defn treewalker [the-tree] | |
(odd? | |
(count (filter (fn [i] (not (false? i))) (flatten the-tree))))) | |
;; (every? #() (tree-seq seq? vec the-tree) ) | |
(def __ treewalker) | |
(= (__ '(:a (:b nil nil) nil)) | |
false) | |
(= (__ '(:a (:b nil nil))) | |
false) | |
(= (__ [1 nil [2 [3 nil nil] [4 nil nil]]]) | |
true) | |
(= (__ [1 [2 nil nil] [3 nil nil] [4 nil nil]]) | |
false) | |
(= (__ [1 [2 [3 [4 nil nil] nil] nil] nil]) | |
true) | |
(= (__ [1 [2 [3 [4 false nil] nil] nil] nil]) | |
false) | |
(= (__ '(:a nil ())) | |
false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment