This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-12-28
Channels
- # announcements (13)
- # babashka (7)
- # beginners (35)
- # calva (23)
- # chlorine-clover (6)
- # cider (12)
- # clj-kondo (6)
- # clojure (31)
- # clojure-dev (20)
- # clojure-europe (4)
- # clojure-norway (4)
- # clojure-uk (1)
- # clojurescript (62)
- # fulcro (6)
- # google-cloud (1)
- # lsp (2)
- # malli (13)
- # meander (6)
- # music (1)
- # off-topic (19)
- # practicalli (2)
- # re-frame (7)
- # reagent (25)
- # reitit (5)
- # releases (1)
- # reveal (3)
- # shadow-cljs (90)
- # tools-build (18)
- # tools-deps (1)
Why doesn't the second example match? cheshire parse-string is giving me an java.lang.Integer and I'm trying to join on some data but it's not matching...
(m/match 1
1 :match
_ :no)
;; => :match
(m/match (Long. 1)
(Long. 1) :match
_ :no)
;; => :no
(type 1)
;; => java.lang.Long
(type (Long. 1))
;; => java.lang.Long
Meander is matching that at the symbol level. It is looking for '(Long. 1)
(m/match (Long. 1)
1 :match
_ :no)
;; => :match
(m/match '(Long. 1)
(Long. 1) :match
_ :no)
;; => :match
If you want to just match all numbers, you can do something like thos
(m/match (Long. 1)
(m/pred number? ?x) :match
_ :no)
good
(let [n (Integer. 2)]
(m/find [n [{:a (Integer. 1)}
{:a (Integer. 2)}]]
[?n (m/scan (m/and {:a ?n} ?t))] ?t))
bad
(let [n (Integer. 2)]
(m/find [{:a (Integer. 1)}
{:a (Integer. 2)}]
(m/scan (m/and {:a n} ?t)) ?t))
Thanks! Yea, I was thinking that it would have the value there but what you said makes total sense. It's term rewriting!