Skip to content

Commit

Permalink
Merge pull request noprompt#205 from rgkirch/patch-2
Browse files Browse the repository at this point in the history
Update cookbook.md
  • Loading branch information
noprompt authored Sep 11, 2021
2 parents f584ed4 + f407962 commit 42a605b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions doc/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ You can leverage self recursion to accumulate a result.
When you have a match pattern that contains a memory varible `!n` and a substitution pattern where you want to make use of the variable in multiple ways, you can't do that directly because `[!n !n]` would take 2 different values out of `!n` instead of the same value twice. However, you can easily create two names for the same value in the search pattern with `(m/and !n !n2)` which will match a single value, but create 2 memory variables.

```clojure
(me/rewrite [[:a 1] [:b 2] [:c 3]]
[[!k (me/and !n !n2)] ...]
[[!k !n (me/app str !n2)] ...])
(m/rewrite [[:a 1] [:b 2] [:c 3]]
[[!k (m/and !n !n2)] ...]
[[!k !n (m/app str !n2)] ...])
;; => [[:a 1 "1"] [:b 2 "2"] [:c 3 "3"]]
```

Expand Down

0 comments on commit 42a605b

Please sign in to comment.