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

I'm having some trouble understanding how `map-of`

works. How would I use it to produce a map of keys to a vector of odd numbers?

```
(m/rewrite {:a [1 2 3]
:b [4 5 6]}
(m/map-of !ks ___)
(m/map-of !ks !vector-of-odds))
```

`map-of`

matches all entries with the key and value pattern respectively, for substitution it builds a map from the key and value patterns respectively.

```
(me/rewrite {:a [1 2 3]
:b [4 5 6]}
(me/map-of !ks (me/gather (me/pred odd? !odds)))
(me/map-of !ks !odds))
;; =>
{:a 1, :b 3}
```

If you’re interested in mapping the keys to their respective odd numbers that would require a bit more effort.

```
(me/rewrite {:a [1 2 3]
:b [4 5 6]}
{?k (me/gather (me/pred odd? !odds)) & ?rest-map}
{?k [!odds ...] & (me/cata ?rest-map)}
?x
?x)
;; =>
{:b [5], :a [1 3]}
```

Thanks, I was thinking about the second case

I see that map-of was the wrong direction to go