This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

## 2021-01-11

## Channels

- # aws (3)
- # babashka (67)
- # beginners (284)
- # calva (19)
- # cider (12)
- # cljdoc (9)
- # clojure (111)
- # clojure-austin (4)
- # clojure-europe (34)
- # clojure-france (12)
- # clojure-greece (2)
- # clojure-nl (14)
- # clojure-taiwan (2)
- # clojure-uk (11)
- # clojurescript (34)
- # community-development (2)
- # conjure (8)
- # datomic (15)
- # events (3)
- # fulcro (12)
- # jobs (3)
- # leiningen (4)
- # malli (3)
- # meander (11)
- # mount (2)
- # off-topic (29)
- # pathom (11)
- # re-frame (31)
- # reagent (19)
- # remote-jobs (3)
- # reveal (8)
- # rewrite-clj (1)
- # sci (1)
- # shadow-cljs (8)
- # spacemacs (4)
- # sql (1)
- # startup-in-a-month (2)
- # tools-deps (2)
- # vim (7)
- # xtdb (6)

Why would the below fail with `Execution error (IllegalArgumentException) at meander.interpreter.epsilon/match-clause-factory$fn$fn$fn (epsilon.cljc:490). Key must be integer`

:

```
(let [q ['?y '?x]
f (mi/searcher
q ['?x])]
(f [:x 1]))
```

```
(defn project
"Helper which extracts the values of vars (keys) out a map in the
order they are given.
Example:
(let [f (mi/finder '[?x ?y] (project '[?y ?x ?y]))]
(f [1 2]))
;; => [2 1 2]"
[vars]
(fn [bindings] (mapv bindings vars)))
(let [q '[?y ?x]
f (mi/searcher
q (project ['?x]))]
(f [:x 1]))
;; => [1]
```

```
(defn debug
[vars]
(fn [bindings]
{:vars vars
:bindings bindings}))
(let [q '[?y ?x]
f (mi/finder
q (debug '?x))]
(f [:x 1]))
;; =>
;; {:vars ?x,
;; :bindings {:meander.interpreter.epsilon/cata #function
;; [meander.interpreter.epsilon/match-system-factory/fn--23289/f--23292] ,
;; ?y :x,
;; ?x 1}}
```

I suspect that if the data being thrown into the function returned by the intrepreter is a vector, it unfolds to something similar

```
(let [date [:x 1])
l ['?y '?x]
r '?x]
(let [idx (.indexOf l r)]
(.get data idx)))
```

I guess this is a bug, because if idx is `nil`

, the rest of the function should not be continued.

If you want to do something a bit more complicated then you should create a function that takes a query and that returns a function that takes a hasmap with the bindings.

```
(let [q '[?y ?x]
f (mi/finder
q {:a '?x})]
(f [:x 1]))
;; => nil
(let [q '[?y ?x]
f (mi/finder
q ((fn [x] (fn [bindings] {:a (get bindings x)})) '?x))]
(f [:x 1]))
;; => {:a 1}
```

Although IMHO does not make sense, it is better to build the collection that we need after obtaining the value

Will take a look at this later today is someone else doesn't get to it first.