This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-11-17
Channels
- # beginners (69)
- # calva (25)
- # cider (12)
- # cljdoc (17)
- # cljs-dev (60)
- # clojure (67)
- # clojure-spec (2)
- # clojure-uk (17)
- # clojurescript (46)
- # cloverage (1)
- # code-reviews (6)
- # cursive (3)
- # datascript (8)
- # figwheel-main (1)
- # fulcro (13)
- # hyperfiddle (25)
- # off-topic (7)
- # re-frame (24)
- # reagent (12)
- # reitit (24)
- # ring (8)
- # spacemacs (11)
- # specter (22)
- # tools-deps (7)
- # unrepl (1)
what do y'all think about this for quick and dirty predicate dispatch? https://stackoverflow.com/questions/53329709/dispatching-function-calls-on-different-formats-of-maps/53354967#53354967
@john it seems because you're using a {}
to store the impls, when a value satisfies multiple predicates, which one gets dispatched is random, isn't it? How about (def poly-atom (atom (array-map)))
? That way we can implement prefer-method
?
This is first time I've seen predicate dispatch so I have no idea what I'm talking about.
@jaihindh.reddy I updated the example a bit, to read a bit clearer. Particular poly
s, like myinc
s or take-turn
s are stored as keys in the map. Their predicate implementations are conj
ed to a vector of vectors which contain pairs of predicates and functions, which apply to the params when the predicate returns true with the params.
prefer-method
enhancement would need to replace the filtering functionality that runs over those pairs
Oops. The comment cleared it up. Got it.