Advertisement
CLooker

Untitled

Dec 25th, 2017
1,235
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;produce fn that tests if input is a palindrome
  2. ;(false? (__ '(1 2 3 4 5)))
  3.  
  4. (defn reverse-seq [some-seq]
  5.   (reduce,
  6.   (fn [new-vec curr]
  7.     (cons curr new-vec)),
  8.   [],
  9.   some-seq))
  10.  
  11. (defn is-palindrome [some-seq]
  12.  (= some-seq (reverse-seq some-seq))
  13.  
  14. (is-palindrome '(1 2 3 4 5))
Advertisement
RAW Paste Data Copied
Advertisement