When calling a function that returns something the REPL prints the output. How to suppress this printing without resorting to temporarily adding nil
as the last line in a function?
Asked
Active
Viewed 1,100 times
5

m33lky
- 7,055
- 9
- 41
- 48
-
Why would you need such functionality? Is the output too large or something else? – OlegTheCat Mar 18 '17 at 16:43
1 Answers
7
This is fairly easy to do. If, for instance, you have a function named f
, then as you know, you can call it like this:
(f)
;; hello yes this is f
;;=> :huge
But if you want to ignore the output, you can do this instead:
(do (f) nil)
;; hello yes this is f
;;=> nil
You could also define an ignore
function to do this for you if you feel like it:
(def ignore (constantly nil))
(ignore (f))
;; hello yes this is f
;;=> nil

Sam Estep
- 12,974
- 2
- 37
- 75
-
1I find myself playing with `->>` during development a lot, so defining such an ignore function will be useful. Also, this topic is related: http://stackoverflow.com/questions/25417958/suppress-the-printing-of-the-data-an-atom-holds-in-the-repl-or-ref-agent – m33lky Mar 18 '17 at 21:11