This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-11
Channels
- # architecture (1)
- # babashka (61)
- # babashka-sci-dev (1)
- # beginners (85)
- # calva (112)
- # clj-kondo (279)
- # cljdoc (16)
- # cljs-dev (15)
- # cljsrn (7)
- # clojure (168)
- # clojure-europe (36)
- # clojure-nl (10)
- # clojure-spec (6)
- # clojure-uk (5)
- # clojured (1)
- # clojurescript (20)
- # core-async (16)
- # crypto (2)
- # cursive (13)
- # datomic (25)
- # events (7)
- # fulcro (21)
- # google-cloud (3)
- # graalvm (2)
- # graalvm-mobile (2)
- # gratitude (3)
- # helix (20)
- # honeysql (4)
- # hugsql (15)
- # introduce-yourself (15)
- # leiningen (2)
- # lsp (24)
- # luminus (22)
- # malli (21)
- # meander (11)
- # midje (1)
- # other-languages (1)
- # pathom (8)
- # re-frame (5)
- # reagent (5)
- # releases (2)
- # reveal (1)
- # shadow-cljs (18)
- # spacemacs (17)
- # sql (9)
- # tools-build (12)
- # tools-deps (4)
- # vim (12)
hey y'all I'm trying to write a pattern to match lists with two or more items, and I'm seeing the "n or more" operator match on a empty list when I use it in an m/search
- here's what I'm seeing:
(m/match
[]
[_ ..2] :matched-two-or-more
_ :didnt-mach)
;; => :didnt-mach
(m/search
[]
[_ ..2] :matched-two-or-more)
;; => (:matched-two-or-more)
Is this expected behavior? I would assume that [_ ..2]
means 2 or more elements in the list🤷 1
This looks like a bug. Could you file it in the issue tracker? As a temporary work around try
[_ _ & _]
sure thing -- will do! FWIW, the pattern I ended up using was [_ . _ . _ ...]
but [_ _ & _]
worked as expected as well
alright, https://github.com/noprompt/meander/issues/228#issue-1133344037 - lmk if there's anything else I can help with
đź‘Ť 1
(m/defsyntax
compare-op
[op a b]
(case op
:eq `(= ~a ~b)
:not-eq `(not= ~a ~b)
:lt `(< ~a ~b)
:lt-e `(<= ~a ~b)
:gt `(> ~a ~b)
:gt-e `(>= ~a ~b)
:is `(= ~a ~b)
:is-not `(not= ~a ~b)
:in `(some #{~a} ~b)
:not-in `(not (some #{~a} ~b))))
(m/rewrite {:node :eq
:a 1
:b 2}
{:node :eq
:a ?a
:b ?b}
(compare-op :eq ?a ?b))
;; (clojure.core/= 1 2)
(m/rewrite {:node :eq
:a 1
:b 2}
{:node ?op
:a ?a
:b ?b}
(compare-op ?op ?a ?b))
;; 1. Caused by java.lang.IllegalArgumentException
;; No matching clause: ?op
How can I understand what’s going on here?