Fork me on GitHub
#meander
<
2023-02-08
>
hanDerPeder21:02:38

(match [1]
  [!x ...] (subst [(+ 1 !x) ...])) ;; => [(+ 1 1)]
is it possible to get this to return [2] using subst?

xificurC21:02:43

why not just (match 1 ?x (inc ?x))?

hanDerPeder21:02:07

doing something else, but trying to simplify the example to focus on my issue

xificurC21:02:44

user=> (m/match 1 ?x (m/subst ~(+ 1 ?x)))
2

hanDerPeder21:02:37

doesn't work since it's a memory variable in my example.

(match [1 2 3]
  [!x ...] (subst [(+ 1 !x) ...]))

jgdavey21:02:10

There are a bunch of ways to “apply”, including the unquote and m/app

hanDerPeder21:02:31

m/app might be what I'm looking for

hanDerPeder21:02:39

(match [1 2 3]
  [!x ...] (subst [(app (partial + 1) !x) ...]))
;; => [2 3 4]
👍

hanDerPeder21:02:10

why cant unqoute work with memory variables?

jgdavey21:02:43

I’m not sure of the limitations, but I do know that unquote-splice is a known thing that doesn’t work

jgdavey21:02:53

perhaps related?

hanDerPeder21:02:47

could be. my understanding of meander is pretty surface level at the moment

xificurC21:02:55

(app (partial + 1) !x) is just (app inc !x)

👍 4
hanDerPeder21:02:13

my current workaround

(match [1]
  [!x ...] (mapv #(+ 1 %) !x)) ;; => [2]