meander 2023-02-08

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

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

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

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

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

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

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

m/app might be what I'm looking for

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

why cant unqoute work with memory variables?

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

perhaps related?

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

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

👍 2

my current workaround

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