Skip to content

Instantly share code, notes, and snippets.

@practicalli-johnny
Forked from jennifersmith/gist:1968416
Last active April 6, 2016 17:39
Show Gist options
  • Save practicalli-johnny/2037502 to your computer and use it in GitHub Desktop.
Save practicalli-johnny/2037502 to your computer and use it in GitHub Desktop.
Ldnclj dojo - Palindrome detector
(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