These are chat archives for ramda/ramda

25th
May 2016
Tobias Pflug
@gilligan
May 25 2016 07:18
hm, suggestions for easiest way of applying a list of functions to a single value?
Vladimir Starkov
@iamstarkov
May 25 2016 07:25
@gilligan unapply(ap([...]))
Tobias Pflug
@gilligan
May 25 2016 07:26
cheers
Tobias Pflug
@gilligan
May 25 2016 07:42
@iamstarkov sorry, can you actually give me an example?
Tobias Pflug
@gilligan
May 25 2016 07:52
ah never mind
it's quite obvious
Scott Sauyet
@CrossEye
May 25 2016 11:31
@gilligan: see also juxt and applySpec
Scott Sauyet
@CrossEye
May 25 2016 11:43
@LeonineKing1199: think of sortBy as a transformation of your item into a sort key. That sort key will then be used by standard JS sorting mechanisms. It's not hard to transform yours into what you want, though: http://goo.gl/2sLTKP.
LeonineKing1199
@LeonineKing1199
May 25 2016 16:47
@CrossEye Yeah, I figured that. I was just surprised by the results, is all. Maybe it's my misinterpretation? I did also learn that JS will default String everything when sorting which is something I was unaware of. I assumed (never assume T_T) that JS would use a default comparison between the two types without any sort of conversion. Though it is weird that JS allows for nonsensical operations to happen anyway.
But this got me thinking, Ramda doesn't have any gather, scatter or sortByPredicate functions. If I branched Ramda and made a PR with implementations, would those get looked at?
LeonineKing1199
@LeonineKing1199
May 25 2016 16:57
Ah, screw it. I'm gonna implement the functions anyway :)
Lewis
@6ewis
May 25 2016 17:26
const state = {
   uniqueKey: 0,
   data: "data",
   aliases: [
        {uniqueKey: 0,
        value: null,
        label: null},
       {uniqueKey: 1,
        value: null,
        label: null}
   ]
    };

const uniqueKeyExistInState = R.contains(1, R.map(R.prop('uniqueKey'), state.aliases));

uniqueKeyExistInState
;; do you have a a more succinct solution?
Brad Compton (he/him)
@Bradcomp
May 25 2016 18:42
Lewis
@6ewis
May 25 2016 18:46
@Bradcomp thanks but that's about the same thing :p
Brad Compton (he/him)
@Bradcomp
May 25 2016 18:48
I like any because it will allow you to apply the predicate function directly to the array, instead of having to map first. Not necessarily more succinct, but different and neat :-D
Scott Sauyet
@CrossEye
May 25 2016 19:34
@LeonineKing1199: do look at various existing Ramda functions such as groupBy, groupWith, partition, sort, comparator.
Taylor Hurt
@thurt
May 25 2016 19:55
@chb0github http://goo.gl/vZuBqS I had to wrap the recurse call in a function, otherwise I get stack overflow
Christian Bongiorno
@chb0github
May 25 2016 22:25
@thurt that's actually more code than just writing the recursion yourself!
Taylor Hurt
@thurt
May 25 2016 22:39
@chb0github lol true true
LeonineKing1199
@LeonineKing1199
May 25 2016 22:45
For some reason, the thought of a binary tree in JavaScript freaks me out...