clojurelighttable

How to execute clojure function with no arguments


I have a clojure function defined which takes no arguments.

example

(defn m
[]
...)

How do I execute this function in light table..

(m) or(m nil) or anyway.

using (m) and (m nil) I didn't get any output


Solution

  • To run that function you first need to evaluate the function definition – hit Ctrl+Enter with the cursor on any of the lines of the function definition. Then you should be able to evaluate a line with code that calls your function, i.e. (m).

    When you evaluate Clojure code Light Table needs to connect to your code's Leiningen project (if you have one), it may connect to "LightTable-REPL" if there isn't one, or you can tell it to connect to the "Light Table UI" instead (if you want to play with Light Tables's code inside of LT itself).

    It's also possible that your function doesn't have a return value, like if it only calls other functions (e.g. print) that are intended to have side effects but not a useful return value. But even in that case you should see nil printed in your Clojure file when you evaluate the line containing your function call.

    If you're still having trouble, feel free to ask for help in the Light Table Gitter room, the Google Groups group, or, if you think you've found a bug, open an issue on GitHub.