Created
January 30, 2016 13:33
-
-
Save alwx/72236565ecdd4d818ca6 to your computer and use it in GitHub Desktop.
How transducers work (from https://www.youtube.com/watch?v=6mTbuzafcII)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn filtering [pred] | |
(fn [step] | |
(fn [r x] (if (pred x) (step r x) r)))) | |
(defn my-filter | |
([pred coll] | |
"Returns the result immediately" | |
(reduce ((filtering pred) conj) | |
[] coll)) | |
([pred] | |
"Return the step function to use it later" | |
((filtering pred) conj))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment