Advertisement
CLooker

Untitled

Dec 25th, 2017
1,715
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;palindrome check
  2. ;(false? (__ '(1 2 3 4 5)))
  3. ;(true? (__ "racecar"))
  4.  
  5. (defn reverse-seq [some-seq]
  6.   (reduce,
  7.   (fn [new-vec curr]
  8.     (cons curr new-vec)),
  9.   [],
  10.   some-seq))
  11.  
  12. (defn is-palindrome [some-seq]
  13.  (= some-seq (reverse-seq some-seq)))
  14.  
  15. (is-palindrome '(1 2 3 4 5))
  16.  
  17. ((fn [some-seq]
  18.  (=
  19.     some-seq
  20.     (fn [some-seq]
  21.       (reduce,
  22.       (fn [new-vec curr]
  23.       (cons curr new-vec)),
  24.       [],
  25.       some-seq))
  26.   )
  27. ) '(1 2 3 4 5))
  28.  
  29. (is-palindrome "racecar")
  30. (apply str (reverse-seq "racecar"))
  31. (reverse-seq "racecar")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement