Skip to content

Instantly share code, notes, and snippets.

@RSNara
Created December 31, 2015 04:12
Show Gist options
  • Save RSNara/08c4fefa830bf3a53876 to your computer and use it in GitHub Desktop.
Save RSNara/08c4fefa830bf3a53876 to your computer and use it in GitHub Desktop.
A lazy implementation of filter.
(defn my-filter [predicate? collection]
(lazy-seq
(loop [[head & tail] collection]
(if (predicate? head)
(cons head (my-filter predicate? tail))
(if (seq tail)
(recur tail)
())))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment