I would like to share with you the joy of being able to finally make something working in Clojure.
This is a very simple program solving a very simple problem usually described in any IT University: palindrome detection.
My solution is not the most elegant and short one but it gave me the possibility to practice with Vectors.
Obviously any suggestion is more than welcome, thank you!
(defn is-letter [letter]
(and (> (int letter) (int \A)) (< (int letter) (int \z))))
([word] (let [length (count (seq word))
letter-vector (vec (filter #(is-letter %1) (seq (.toUpperCase word))))]
(check-palindrome letter-vector 0 (- (count letter-vector) 1) )
([letters start end ] (cond
(< end start) (Exception. "The string is NOT a palindrome")
(not (= (letters start) (letters end))) (Exception. "The word is NOT a palindrome")
(or (= start end) (= 1 (- end start))) (println "The string is a palindrome")
:else (recur letters (inc start) (dec end)))
(check-palindrome "Murder, for a jar of red rum")
I was joking with my colleagues today about which one is the best between iPhone and Android.
One of my colleagues said: Based on a statistic (no origin provided ) iPhone owners are wiser.
Then I asked: What do you think Einstein would own?
As you might guess, my answer was Android. Android phones are customizable, are varied, are open (kinda of) so to me the answer was obvious.
Einstein would have been able to disclose his mobile phone’s source code, he would have been able to create applications on it for free using any computer he wanted (I wonder if he would own a Mac), he would have been able to fix bugs on his mobile himself. He would have been able to store files on his mobile phone using ANY computer without installing any software. And finally he would have been able to make his phone his unique phone, different from anyone else’s. That’s why I think he would have chosen an Android phone.
Now, I’m very curious to know what others think about this. So, please give me (and the community) your feedback and let’s see if my colleague was right.