Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

suppress output in REPL

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?

like image 418
m33lky Avatar asked Mar 18 '17 16:03

m33lky


1 Answers

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
like image 178
Sam Estep Avatar answered Oct 28 '22 18:10

Sam Estep