Problem Write a function steps, that takes a sequence and makes a deeply nested structure from it: (steps [1 2 3 4]) ;=> [1 [2 [3 [4 []]]]] Solution 1 (defn steps s) Solution 2 Lazy version: (defn lz-steps s) Note To see the difference, call the function like this:

# programming kata

Problem Suppose a binary tree structure looks like this: {:val value :L <left-node> :R <right-node>} Write a function to balance insert node into the tree. Solution (defn insert tree x) Note Here is the function to traverse the tree: (defn traverse tree) Here is a helper function to create a tree.

Problem Write a function to determine if a vector contains a set of items. Solution (defn containsv v & items) Note Using a set as the predicate supplied to some allows you to check whether any of the truthy values in the set are contained within the given sequence. This is a frequently used Clojure idiom for searching for containment within a sequence.

Problem Write a function to determine if a number is a triangular number. Solutions Solution 1 (defn nth-triangle n) (defn is-triangle-number n) Solution 2 (defn is-triangle-number n) Note Solution 1 is the first that came to my mind, but it has a typical problem: redundant calculation.

Solving hard puzzle programming challenges with logic programming is real fun. I solved one puzzle called “Perfume Shop Puzzle” by using the core.logic in Clojure. Check it out here: github.