Skip to content

Instantly share code, notes, and snippets.

Created December 1, 2009 20:35
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 anonymous/246622 to your computer and use it in GitHub Desktop.
Save anonymous/246622 to your computer and use it in GitHub Desktop.
(def qq [ 1 -1 3 4 -4 -5 6 -10 1345 -32 ] )
(defn filter-neg[g]
(if (neg? g)
[ g (* -1 g)]))
(filter-neg 3)
(defn produce-with-fun[x prod-fun]
(lazy-seq
(when (seq x)
(if-let [f (prod-fun (first x))]
(cons f (red (rest x) prod-fun))
(red (rest x) prod-fun)))))
(produce-with-fun qq filter-neg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment