I’ve attended London Clojure Dojo today, and an overwhelmingly appealing option was something with klipse.
So here’s an attempt.
Note that each clojure block is editable. And will instantly evaluate as you type (just that sexp). A single repl is shared by all the blocks on this page. You need to modify a block to run the block.
(+ 1 4)
Define a function that doubles it’s argument.
Call the function from above!
How do I do string interpolation? You don’t, just call str on a list
A clojure function will evaluate to it’s last item
How about conditionals?
Truthy things
A single quote before parens says “Don’t treat this list as a function call, it is really a list!”. An empty list is ‘()
Vectors are like arrays in other languages, but without the horrific mutability stuff. You want them instead of lists when you want fast-indexing to the middle of the datastructure. Empty Vectors are ‘[]. Note that we’ve already seen vectors above, clojure uses them for parameter lists in functions!
Let’s compare a non-empty list to a non-empty vector