Skip to content

Instantly share code, notes, and snippets.

@jwalsh
Forked from jennifersmith/gist:1968416
Created March 19, 2012 16:29
Show Gist options
  • Save jwalsh/2118241 to your computer and use it in GitHub Desktop.
Save jwalsh/2118241 to your computer and use it in GitHub Desktop.
(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