Fork me on GitHub
Drew Verlee14:03:17

I’m looking to do something close in functionality to what this clojure code does in java:

//define some transition functions
(defn t [] true)
(defn f [] false)

// create a state machine where "not sent" is our starting state and we can transition to "send" or "not send" if their functions t or f eval to true.
(def fsm {"not sent" {t "send"
                      f "not send"

// map over transition functions can if they eval to true then record the reachable state.
(map (fn [[func state]] (if (func) state nil))
 (fsm "not sent")) 

// output of evaling the above code: ("send" nil)
However i seem to be stuck in a couple spots 😕. I’m using instance instead of hash-maps (as i assume one does in java), so i was hoping to use reflection at run time to discover the classes methods then call them. Would this be reasonable or is the approach flawed?