Fork me on GitHub
#specter
<
2016-06-04
>
luxbock13:06:58

is there anything in specter that would allow me to do the following without resorting to the core functions I'm currently using: (reduce + (map count (select [VALS] {:a [1 2 3] :b [5 6]}))), or (reduce + (vals (transform [VALS] count {:a [1 2 3] :b [5 6]}))) ?

nathanmarz13:06:03

is this what you want? (select-one [(subselect ALL LAST ALL) (view count)] DATA)

nathanmarz13:06:18

you could also do (count (select [ALL LAST ALL] DATA))

luxbock13:06:17

yeah both of those work, thanks

luxbock13:06:27

I'm in a phase where I'm trying to figure out where the line between using specter to do things, and having to break out of it to use the core functions is

luxbock13:06:57

that line is probably quite high once you get familiar with all the features packed in 🙂

nathanmarz13:06:03

I'm still in that phase 🙂

nathanmarz13:06:42

the line has gotten higher and higher over time as I've realized how many things can be expressed elegantly in terms of navigation

luxbock13:06:56

it feels a bit like when I first got comfortable with thinking about all Clojure problems as just transforming data back and fourth beetween the core data types and functions, it feels great!

nathanmarz13:06:29

assuming your learning trajectory is similar to what mine was, prepare for a very rewarding ride

nathanmarz13:06:29

a big moment for me was figuring out the "sub{x}" navigators

nathanmarz13:06:45

subset and then subgraph

benzap22:06:01

If I have a row-major matrix, would this be the best way to retrieve a sub-matrix? `

benzap22:06:12

(defn NAV-SUBMAT [i j rows cols] [specter/ALL (specter/srange i (+ i cols)) [(specter/srange j (+ j rows)) specter/ALL]])

benzap22:06:08

oh woops, that doesn't work

benzap22:06:47

This is what I was doing before, but I feel like it can be better `(->> content (specter/select [specter/ALL (specter/srange col-offset (+ cols col-offset))]) (specter/select [(specter/srange row-offset (+ rows row-offset)) specter/ALL]))`

benzap23:06:17

it was backwards, this seems to work: (defn NAV-SUBMAT [i j rows cols] [[(specter/srange j (+ j rows)) specter/ALL] (specter/srange i (+ i cols))])