Created
March 17, 2018 03:29
-
-
Save Sophia-Gold/fd146cf5b4aafc35856f3c95f835ce0e to your computer and use it in GitHub Desktop.
Difference Lists in Clojure
This file contains hidden or 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 dl | |
| [& elements] | |
| (fn [x] (concat elements x))) | |
| (defn dl-un | |
| [l] | |
| (l nil)) | |
| (defn dl-concat | |
| [& lists] | |
| (fn [x] ((apply comp lists) x))) | |
| (def example (dl-un (dl-concat (dl 1) (dl 2 3) (dl) (dl 4)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment