meander

hanDerPeder 2023-02-08T21:15:38.100219Z

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

xificurC 2023-02-08T21:20:43.072819Z

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

hanDerPeder 2023-02-08T21:21:07.859179Z

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

xificurC 2023-02-08T21:21:44.961919Z

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

hanDerPeder 2023-02-08T21:23:37.203659Z

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

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

jgdavey 2023-02-08T21:24:10.065109Z

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

hanDerPeder 2023-02-08T21:24:31.322279Z

m/app might be what I'm looking for

hanDerPeder 2023-02-08T21:25:39.444829Z

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

hanDerPeder 2023-02-08T21:26:10.098599Z

why cant unqoute work with memory variables?

jgdavey 2023-02-08T21:26:43.648669Z

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

jgdavey 2023-02-08T21:26:53.074749Z

perhaps related?

hanDerPeder 2023-02-08T21:27:47.219509Z

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

xificurC 2023-02-08T21:27:55.188509Z

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

👍 2
hanDerPeder 2023-02-08T21:20:13.277679Z

my current workaround

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