Created
February 23, 2017 09:38
-
-
Save HakimCassimallyBBC/10fdaec1d1907e758e92403933ada0c8 to your computer and use it in GitHub Desktop.
and-> function to add a parenthesis to a threading form
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
boot.user=> (defn and->> [f value] (doto value f)) | |
#'boot.user/and->> | |
boot.user=> (defn and-> [value f] (doto value f)) | |
#'boot.user/and-> | |
;; use the appropriate and->(>) form for your threading macro | |
boot.user=> (-> 1 (and-> println)) | |
1 | |
1 | |
;; or ignore the value passed in | |
boot.user=> (->> 1 (and->> (fn [_] (println "hello")))) | |
hello | |
1 | |
boot.user=> (-> 1 (and-> (fn [_] (println "hello")))) | |
hello | |
1 | |
;; or perhaps using `constantly`? | |
(-> 1 (and-> (constantly (println "hello"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Suggested enhancement: