Fork me on GitHub
#conjure
<
2020-08-20
>
hoopes00:08:11

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

hoopes00:08:28

(or sends the function to the repl? i’m not sure the details, i’m just learning this editor/repl life)

dave00:08:20

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))

dave00:08:11

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

hoopes00:08:18

huh…i guess if my defn has arguments, just having cursor over it doesn’t really work

hoopes00:08:25

that’s interesting

hoopes00:08:49

thanks for that, appreciate it!

dave00:08:57

sure thing!

mamapitufo11:08:45

another thing you can do is drop vim marks on each of the forms you have inside the comment and use \em<mark>