Created
February 18, 2025 19:30
-
-
Save jgomo3/55a940c58910677ae8eafad4dc0e92f2 to your computer and use it in GitHub Desktop.
Thread macros for elements of a collection
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
(ns map-threads) | |
(defmacro map-> [coll & body] | |
`(for [e# ~coll] | |
(-> e# ~@body))) | |
(defmacro map->> [coll & body] | |
`(for [e# ~coll] | |
(->> e# ~@body))) |
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
(use 'map-threads) | |
(map-> [1 2 3] | |
(- 1) | |
(- 2)) | |
;; => (-2 -1 0) | |
(map->> [1 2 3] | |
(- 1) | |
(- 2)) | |
;; => (2 3 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment