Skip to content

Instantly share code, notes, and snippets.

@amalloy
Forked from halfprogrammer/function-keyword.clj
Created June 14, 2011 17:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amalloy/1025420 to your computer and use it in GitHub Desktop.
Save amalloy/1025420 to your computer and use it in GitHub Desktop.
Keywords as function parameters in clojure?
(defn my-exists1? [lst obj & {:keys [testfn] :or {testfn =}}]
(loop [lst lst, obj obj]
(when lst
(if (testfn (first lst) obj)
lst
(recur (next lst) obj)))))
(my-exists1? '((1 2) (3 4) (5 6)) 3 :testfn #(= (first %1) %2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment