Fork me on GitHub
#meander
<
2021-08-12
>
eoliphant18:08:41

hi i’m trying to do a transform where i need to select a single value out of a list.. something like

{:a "a" 
 :b  [{:name "pickme" :value "foo"} {:name "somethingelse" :value "bar" ..]}
;becomes
{:my/a "a"
 :my/b "foo"}

; have tried various things with ... scan, etc but i'm obivously not doing the right thing
{...
 :b [{:name "pickme" :value !value} ...]}

etc

ribelo18:08:58

(m/rewrite {:a "a"
            :b [{:name "pickname" :value "foo"} {:name "somthingelse" :value "bar"}]}
  {:a ?a
   :b [{:value !value} ...]}
  [{:my/a ?a
    :my/b !value} ...])
;; => [#:my{:a "a", :b "foo"} #:my{:a "a", :b "bar"}]

ribelo18:08:04

Wait, I misread

ribelo18:08:43

You want to get whatever has pickme

eoliphant18:08:55

i got something sorta working with cata

ribelo18:08:36

(m/rewrite {:a "a"
            :b [{:name "pickme" :value "foo"} {:name "somthingelse" :value "bar"}]}
  {:a ?a
   :b (m/scan {:name "pickme" :value !value})}
  {:my/a ?a
   :my/b !value})

;; => #:my{:a "a", :b "foo"}

eoliphant18:08:04

ok cool i thought i tried that but at this point who knows lol

eoliphant18:08:56

ah i was using match instead of rewrite

ribelo18:08:58

Scan does not work with match, but with find it does.

ribelo18:08:05

(m/find {:a "a"
            :b [{:name "pickme" :value "foo"} {:name "somthingelse" :value "bar"}]}
  {:a ?a
   :b (m/scan {:name "pickme" :value !value})}
  {:my/a ?a
   :my/b !value})

eoliphant18:08:32

gotcha. still working through what works with what lol

ribelo18:08:09

and if you don't need to collect multiple values, it's a better idea to use ?value instead of !value

ribelo18:08:05

The learning curve of meander is very steep, I recommend to start with find, only after that play with rewrite, and finally recursion with cata and with

👍 2
eoliphant18:08:43

yeah that’s what threw me a little

eoliphant18:08:17

because i know i wanted a single value ?… but in that context most of the examples are the memory vars !..

eoliphant18:08:36

will use that heuristic going forward

ribelo18:08:42

memory vars will always work too, but they are obviously slower

eoliphant18:08:43

i’ll maybe add that to the docs lol. because it seems simple for a lot of common cases but, yeah there are quite a few dangerous left turns lol

noprompt22:08:11

@U380J7PAQ I merge 100% of patches to our docs. 🙂

3
noprompt19:08:18

Has anyone had a chance to double check if whats on epsilon right now works for them e.g. it passes tests, etc.?

ribelo20:08:18

doxa uses meander very heavily and it also seems to work.

noprompt20:08:34

Awesome. What font is that? I looks almost like Monoid.

ribelo20:08:36

[buildPlans.iosevka-custom]
         family = "Iosevka Custom"
         spacing = "normal"
         serifs = "sans"
         no-cv-ss = true

         [buildPlans.iosevka-custom.variants]
         inherits = "ss04"

         [buildPlans.iosevka-custom.ligations]
         inherits = "dlig"

noprompt20:08:47

Ah, nice. I knew it looked familiar. 🙂

ribelo20:08:51

A good font is essential, I admire people from the previous era who had to look at jagged angular fonts on crt monitors.

noprompt22:08:18

The past couple years have been generous for monospace typography. There are so many fantastic options available.

noprompt22:08:37

Also, I will probably cut a release tomorrow.

noprompt22:08:50

@huxley After that I think we can get back on track with the fast flag.