Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. ; ---------------square----------------------------------
  2.  
  3. (def sqr (comp (partial apply *) (partial repeat 2)))
  4. ; --------------pallindrome-----------------------------------
  5.  
  6. (def trim-ends (comp butlast rest))
  7. (def not-nil (comp not nil?))
  8. (def first-last-equal? (comp (partial apply =) (partial (juxt first last))))
  9. (def is-pallindrome? (comp (partial every? first-last-equal?) (partial take-while not-nil) (partial iterate trim-ends)))
  10. ; ----------------prime---------------------------------
  11.  
  12. (def divides? (comp (partial zero?) (partial rem)))
  13. (def is-prime? (comp (partial apply not-any?) (juxt (partial partial divides? ) (partial range 2))))
  14. ;--------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement