These are chat archives for ramda/ramda

Jul 2015
Scott Christopher
Jul 16 2015 02:08
If you’re still around the place @slifin, I had a crack at porting curry to PHP in your SO link:
It’s not the cleanest implementation, but very few FP concepts seem to adapt cleanly to PHP.
James Forbes
Jul 16 2015 08:33
Hey guys is there something like R.toArray I can't find it.
Scott Christopher
Jul 16 2015 10:48
@JAForbes what type are you wanting to convert to an array?
There is R.of if you just need a singleton array of any value.
R.toPairs for converting an object to an array of key/value pairs
or R.keys and R.values for extracting a list of keys or values from an object.
Adrian Smith
Jul 16 2015 12:37
thank you @scott-christopher in the end I took someone elses library and forked it then hacked in placeholder support : but I feel my attempt is really hacky having another implementation should help me refine it
the maintainer didn't seem happy with placeholder support: camspiers/php-fp#2 not really sure why, feel like maybe I've bastardised his library in a way that isn't immediately obvious to me
he suggested going from left curry to right curry and back again to achieve a similar thing but imo that only supports going outwards inwards
Shane Keulen
Jul 16 2015 17:47
hello, i'm having trouble with ramda again, how would i check if all items in an array are the same
I've tried R.all(R.equals(arr[0]); but arr has been transformed by a pluck previouslky
David Chambers
Jul 16 2015 17:49
You could use R.uniq and see whether the length of the resulting list is <= 1.
Shane Keulen
Jul 16 2015 17:50
is there something like Array.prototype.every
David Chambers
Jul 16 2015 17:51
R.all is pretty close.
Shane Keulen
Jul 16 2015 17:51
currently i have R.compose(R.all(R.equals(R.prop('size',arr[0]))), R.pluck('size'));
that's not really good though
David Chambers
Jul 16 2015 17:53
You want to know whether all the elements of arr have the same size?
Shane Keulen
Jul 16 2015 17:53
yeah basically
ideally without checking them all
var allSize = { return item.size; }) .every(function(el, ind, arr) { return el === arr[0]; });
David Chambers
Jul 16 2015 17:55
The problem is if you want short circuiting you’ll need to add a check to handle the empty list.
Elegant solution (without short circuiting):
> R.uniqBy(R.prop('size'), [{size: 1}, {size: 1}])
[ { size: 1 } ]
> R.uniqBy(R.prop('size'), [{size: 1}, {size: 2}])
[ { size: 1 }, { size: 2 } ]
Not-so-elegant solution (with short circuiting):
                  R.pipe(R.head, R.equals),
Stefano Vozza
Jul 16 2015 21:54

Has anyone actually seen the Ramda iPhone benchmark mentioned here?

Doesn't sound right to me.

John-David Dalton
Jul 16 2015 22:55
:tada: It's not too far fetched really. 14ms for a single iteration multiplied by 1,000.