Programmer. Hiker. Cook. Always looking for interesting problems to solve.
21 Jun 2013 | clojure
I’m getting used to the syntax (parentheses are not scary at all!). And I’m slowly (but surely?) changing the way I think of data structures and functions.
I make mistakes. Some are embarrassing.
When asked to write a function that reverses a sequence (but not using
rseq), my initial solution was this:
(fn [coll] (loop [r (rest coll) result (conj () (first coll))] (if (empty? r) result (recur (rest r) (conj result (first r))))))
I was not really using what Clojure has to offer. It can be done as a one-liner:
#(reduce conj () %)
But I’ll get there!