Skip to content

Instantly share code, notes, and snippets.

@kaskichandrakant
Last active February 21, 2019 03:56
Show Gist options
  • Save kaskichandrakant/6b4afe36e4fbc25731ee4aac74dcfcda to your computer and use it in GitHub Desktop.
Save kaskichandrakant/6b4afe36e4fbc25731ee4aac74dcfcda to your computer and use it in GitHub Desktop.
; ---------------square----------------------------------
(def sqr (comp (partial apply *) (partial repeat 2)))
; --------------pallindrome-----------------------------------
(def trim-ends (comp butlast rest))
(def not-nil (comp not nil?))
(def first-last-equal? (comp (partial apply =) (partial (juxt first last))))
(def is-pallindrome? (comp (partial every? first-last-equal?) (partial take-while not-nil) (partial iterate trim-ends)))
; ----------------prime---------------------------------
(def divides? (comp (partial zero?) (partial rem)))
(def is-prime? (comp (partial apply not-any?) (juxt (partial partial divides? ) (partial range 2))))
;--------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment