## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
• Jan 31 2019 22:17
CrossEye commented #2779
• Jan 31 2019 21:04
ArturAralin commented #2779
• Jan 31 2019 20:08
CrossEye commented #2779
• Jan 31 2019 18:56
buzzdecafe commented #2631
• Jan 31 2019 18:09
ArturAralin commented #2779
• Jan 31 2019 16:18
CrossEye commented #2779
• Jan 31 2019 16:10
CrossEye commented #2631
• Jan 31 2019 16:06
CrossEye commented #2777
• Jan 31 2019 14:44
ArturAralin opened #2779
• Jan 31 2019 07:39
inferusvv commented #2631
• Jan 31 2019 03:07
sespinozj commented #2771
• Jan 31 2019 02:33
• Jan 31 2019 02:26
JeffreyChan commented #2777
• Jan 30 2019 14:30
CrossEye closed #2777
• Jan 30 2019 12:13
• Jan 30 2019 01:42
JeffreyChan commented #2777
• Jan 29 2019 21:06
• Jan 29 2019 16:28
CrossEye commented #2777
• Jan 29 2019 15:50
mbostock commented #2772
• Jan 29 2019 15:48
CrossEye commented #2772
Scott Sauyet
@CrossEye
We're having lots of discussions right now about compose/pipe, and we need to figure out how to deal with this.
This did work in v15: http://bit.ly/1O0uEki
But it broke in 16.
ramda/ramda#1318 discusses some of the problems.
Matthew Steedman
@knubie
Hi, I'm wondering, is there a variadic version of R.concat?
Matthew Steedman
@knubie
i was attempting to write R.converge(R.concat, fn1, fn2, fn3) but instead had to write R.converge(R.concat, R.converge(R.concat, fn1, fn2), fn3)
Scott Sauyet
@CrossEye
Ramda doesn't have one. You could probably define one as:
var concatAll = R.unapply(R.reduce(R.concat, []));
And then:
R.converge(concatAll,
R.map(R.multiply(3)),
R.map(R.flip(R.divide)(2))
)([2, 4, 6]);
//=> [3, 5, 7, 6, 12, 18, 1, 2, 3]
Matthew Steedman
@knubie
I see, thanks!
trbrc
@trbrc
so. i've been using ramda for a couple of months now.
and I'm really in love with the idea. but I don't know, maybe I'm alone in feeling this... it feels like whenever I try to do anything real by composing ramda functions, i always go down a rathole.
like i'm spending hours doing something that would take minutes with some plain old imperative code.
and when I return to my code later, it seems completely incomprehensible.
is this normal? have I just not reached zen yet?
trbrc
@trbrc
i asked a question here two weeks ago or so about the best way to do something, and solved it with some help from the channel. but then it turns out... i hadn't solved it at all. the solution just randomly happened to work for the one test case i used as an example.
so despite several people looking at my snippet, not a single person was able to spot the fact that the code was not even remotely doing what i wanted to.
sorry if that sounded harsh, not what I intended to. just wanted to discuss this a bit.
is just makes me think that coding by composing functions just makes things very hard to reason about.
Scott Sauyet
@CrossEye
I'd love to hear more about where it's failing for you. My experience is precisely the opposite. By building my code out of smaller, simpler functions, I almost always find it easier to reason about.
trbrc
@trbrc
in many cases yes, it can be very elegant and expressive.
i don't know exactly what the problems i run into have in common. maybe when there are many things that need to checked or compared to figure out the final value i want.
maybe there are tools in the toolbox i should use, that i haven't figured out yet.
for the stuff i'm working on right now, there are a lot of objects/hashes, where I need to do things based both on the keys and values. that seems to bring a huge amount of friction compared to working with arrays/lists.
Scott Sauyet
@CrossEye
It might simply be that Ramda isn't well-suited for your data structures. That would be a shame, and I'd love to see if we could help, but it's certainly possible.
trbrc
@trbrc
maybe. i'm not sure how to find old messages in gitter, but that issue that i had a while back was getting the maximum value in a list, by scoring every item with a function.
here's my best attempt at doing it using only ramda.
function scoreBy(fn, list) {
const scores = R.map(fn, list);
const zipped = R.zip(scores, list);
return R.last(R.last(scored));
}
that's crazy. it seems completely opaque to me, glancing over it.
Simon Friis Vindum
@paldepind
Why can't you do R.sortBy(fn, list).
trbrc
@trbrc
that's a good question, that seems like it should work.
R.last(R.sortBy(fn, list)) ? maybe it's that simple.
Scott Sauyet
@CrossEye
.... although a sort just to find a max sounds like the wrong algorithm. If the data is small enough that should be fine.
Simon Friis Vindum
@paldepind
I agree that the current code is quite convoluted.
trbrc
@trbrc
i guess what i mean is that it feels a bit like a puzzle to me. it's easy to lose track and get lost.
this should probably be done better using reduce.
if i write the same code using a for loop i don't really need to think about it, all the stuff i need to look at is right there.
but maybe it's just because i've been writing imperative code for so long.
Scott Sauyet
@CrossEye
There definitely is an adjustment period.
But note that this can be written fairly simply as R.useWith(R.reduce, R.maxBy). http:// bit.ly/1KnFLGv
trbrc
@trbrc
thanks, i just rewrote it using reduce, but i would never have figured out that i could use useWith.
so i guess at least part of my issue that i have not yet internalized the different building blocks i might use to solve a problem.
so I end up using the wrong ones.
Scott Sauyet
@CrossEye
useWith and converge are oddballs. Don't feel bad at all about not thinking about them. They are quite useful though when you get to know them.
trbrc
@trbrc
maybe part of it is that it's hard to put words on what some of these functions do. like, "use with" could mean a lot of things.
it seems like a lot of functional programming tools deal with these patterns underlying what you're trying to do. they're not always so easy to see.
Scott Sauyet
@CrossEye
And we need very soon to have our summit on the various compose-related functions. They've become something of a mess.
hemanth.hm
@hemanth
Trying to reduce:
R.uniq(R.keys(R.values(R.pick(['name','age'],data))[0])).sort()
David Chambers
@davidchambers
Rather than R.values(R.pick(['name', 'age'], data)) you could use R.props(['name', 'age'], data).
hemanth.hm
@hemanth
Nice, so it's like R.keys(R.prop(['name'],data)).sort()