Skip to content

Instantly share code, notes, and snippets.

@ztellman
Created October 5, 2016 23:43
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 ztellman/243a311cae5da7b9ef89fa2e23a36ee3 to your computer and use it in GitHub Desktop.
Save ztellman/243a311cae5da7b9ef89fa2e23a36ee3 to your computer and use it in GitHub Desktop.
(defmacro if-in-str [haystack & clauses]
`(do
~@(map
(fn [clause]
(let [needle (first clause)
is-present-form (second clause)
is-not-present-form (nth clause 2 nil)]
`(if (> (.indexOf ~haystack ~needle) -1)
~is-present-form
~is-not-present-form)))
clauses)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment