This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-20
Channels
- # arachne (4)
- # bangalore-clj (1)
- # beginners (38)
- # boot (182)
- # cider (21)
- # cljs-dev (9)
- # clojars (5)
- # clojure (229)
- # clojure-austin (1)
- # clojure-berlin (1)
- # clojure-czech (3)
- # clojure-dusseldorf (3)
- # clojure-ireland (5)
- # clojure-italy (4)
- # clojure-russia (33)
- # clojure-spec (73)
- # clojure-taiwan (6)
- # clojure-uk (22)
- # clojure-ukraine (1)
- # clojurescript (80)
- # core-async (26)
- # cursive (3)
- # datascript (20)
- # datomic (9)
- # defnpodcast (8)
- # editors (4)
- # emacs (7)
- # garden (41)
- # hoplon (2)
- # java (1)
- # lambdaisland (2)
- # lein-figwheel (1)
- # leiningen (5)
- # luminus (4)
- # lumo (36)
- # off-topic (4)
- # om (21)
- # onyx (1)
- # pedestal (33)
- # re-frame (33)
- # ring-swagger (70)
- # spacemacs (26)
- # specter (7)
- # sql (6)
- # timbre (2)
- # untangled (12)
- # vim (3)
- # yada (1)
#java2017-03-20
>
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?