if i’m on a defn
, \ee
just redefines the function - i’d like to actually call the function from my editor in the repl
(or sends the function to the repl? i’m not sure the details, i’m just learning this editor/repl life)
a common convention is to add a comment
form to the bottom of the file (or maybe even write below the function) and write whatever code you want in there. clojure programmers are generally accepting of keeping scratch code in the same file as the implementation code
so for example, you might write something like this:
(defn multiply-by-3
[x]
(* x 3))
(comment
(multiply-by-3 7)
(multiply-by-3 Math/PI)
(multiply-by-3 "lol not a number")
(multiply-by-3 nil))
the clojure reader skips over (i.e. doesn't evaluate) everything in the comment
form, so you can put pretty much anything in there
meanwhile, you can place your cursor inside any of those (multiply-by-3 ...)
forms and press \ee
and it will evaluate the form and show you the result
huh…i guess if my defn
has arguments, just having cursor over it doesn’t really work
that’s interesting
thanks for that, appreciate it!
sure thing!
another thing you can do is drop vim marks on each of the forms you have inside the comment
and use \em<mark>