Clojure’s been strange so far. After tinkering in F# for the last couple months, it seems like functional programming should be easier by now.
Reverse and palindrome were easy enough, though.
; P05 (*) Reverse a list. ; clojure already has a (reverse l) (defn s99_reverse [l] (loop [remain l curr '()] (let [head (first remain) tail (rest remain)] (if (nil? head) curr (recur tail (cons head curr))))) ; P06 (*) Find out whether a list is a palindrome. (defn isPalindrome [l] (= l (reverse l)))
I’m slowly getting my brain around the lisp like syntax, but it appears that some of the idioms are different. I’ll discuss this more when I get to the next set.