Fork me on GitHub
#specter
<
2016-06-02
>
luxbock04:06:50

how would I write the following using Specter: `

luxbock04:06:29

(into {} (for [[k v] fff] [k (mapv :foo v)]))

luxbock04:06:57

where fff is {:x [{:foo "hello" :bar [2 4]} {:foo "there"}] :y [{:foo "moo" :bar [2 4]} {:foo "world"}]}

luxbock04:06:09

and the desired output is {:x ["hello" "there"], :y ["moo" "world"]}

luxbock04:06:45

my problem is that all of my attempts at selecting the key :foo throw away the surrounding context of the vector

nathanmarz04:06:46

@luxbock: (transform [ALL LAST ALL] :foo fff)

luxbock04:06:13

@nathanmarz: thanks, I finally got it but my way was using select-one which I guess I don't need

nathanmarz04:06:27

what did your select-one solution look like?

luxbock04:06:21

(transform [VALS ALL (collect-one :foo)] (fn [x y] x) fff), where VALS is ALL LAST

luxbock04:06:44

oh yeah, I meant to say collect-one

luxbock04:06:25

how about if I want to return [["hello" "there"] ["moo" "world"]]?

nathanmarz04:06:28

yea, besides being more concise my version will be much faster

nathanmarz04:06:49

(select [ALL LAST (subselect ALL :foo)] fff)

luxbock04:06:58

ah great, thanks again

luxbock04:06:13

yeah subselect is mentioned at the very bottom of the README so I didn't spot it as something I should've looked into

luxbock04:06:29

there are currently no API docs for specter right?

nathanmarz04:06:46

well the files themselves are documented

nathanmarz04:06:55

I suppose I should generate some html

luxbock04:06:34

I also noticed that many of the core functions lack doc strings

nathanmarz04:06:26

specter.cljx mostly has docstrings

nathanmarz04:06:47

but yea I agree the docs could use substantial work

nathanmarz05:06:35

@luxbock: Any suggestions for documentation improvements would be appreciated https://github.com/nathanmarz/specter/issues/56

luxbock06:06:31

it appears that collect and collect-one are identical

nathanmarz06:06:49

same difference as between select and select-one

luxbock06:06:55

ah, yeah you are right, I misread the source. need more coffee