In Scheme, I can use define-struct
to make a binary search tree, but how do you do it in Clojure?
You can use structmaps. To define one:
(defstruct bintree :left :right :key)
To make an instance:
(struct-map bintree :left nil :right nil :key 0)
You can then access the values in the struct like this:
(:left tree)
etc.
Or you can create new accessor functions:
(def left-branch (accessor bintree :left))
and use it:
(left-branch tree)