Fork me on GitHub
#meander
<
2021-05-11
>
ribelo20:05:11

what is the simplest way to use the same value several times?

ribelo20:05:02

(m/rewrite [:a :b :c :d]
  ;; something I don't know
  ;;
  )
;; =>
;; [{:key1 :a :key2 :a :key3 :b} {:key1 :c key2 :c :key3 d}]

ribelo20:05:49

Okay, I got it 😉

wilkerlucio20:05:20

I'm curious, can you send the solution?

ribelo20:05:21

(m/rewrite [:a :b :c :d]
  [?x ?y & ?more]
  [{:k1 ?x :k2 ?x :k3 ?y} & (m/cata ?more)]
  ?x nil)
;; => [{:k1 :a, :k2 :a, :k3 :b} {:k1 :c, :k2 :c, :k3 :d}]
@U066U8JQJ