These are chat archives for ramda/ramda

25th
Feb 2015
Michael Hurley
@buzzdecafe
Feb 25 2015 00:08
me too. i also don't like that it prints [1, 2, 3] as 1, 2, 3
Scott Sauyet
@CrossEye
Feb 25 2015 00:12
the repl is mostly borrowed from a friend who wrote it for another purpose. I would love to give it a little attention, but it's quite good as it is, so it's low down on my list.
Scott Sauyet
@CrossEye
Feb 25 2015 00:22
Part of the joy of Project Euler is doing them yourself. I actually have posted answers in a secret Gist to about the first 40 Euler problems user Ramda (or even Eweda), written during the early days of writing Ramda. But I haven't shared them publicly. Something seems wrong with doing so.
Scott Sauyet
@CrossEye
Feb 25 2015 00:28
@TheLudd: As well as the ES3 issue, this allowed us to use our own API for map, which is different from the one on Array.prototype and to use an implementation which is so far quite a bit faster than the native ones..
Scott Sauyet
@CrossEye
Feb 25 2015 00:48
@jethrolarson: That sort of unhelpful conversion to points-free is too easy to do. I find myself doing it all the time. I think points-free is great, but we have to be careful to use it only when it actually helps make the code easier to understand.
Hardy Jones
@joneshf
Feb 25 2015 15:43
Re: the Euler problem.
If ramda-fantasy implemented Monad for functions you could do:
var divBy = R.flip(R.modulo).map(R.chain(R.curry(function(a, b) { return a ? 0 : b; })));
var or = R.curry(function(x, y) { return x || y; });
var multiples = divBy(3).map(or).ap(divBy(5));
var sumFantasy = R.map(multiples).map(R.sum);
sumFantasy(R.range(1, 1000)); //=> 233168
Shame about needing to flip modulo and write an or
any opinion about more functions like or?
where it just gives you a function version of the operator?
R.or :: Boolean -> Boolean -> Boolean
Hardy Jones
@joneshf
Feb 25 2015 16:02
like R.add
David Chambers
@davidchambers
Feb 25 2015 16:38
Ramda has an or function (http://ramdajs.com/docs/#or), but it takes two functions and returns a function. Sanctuary has an or function similar to the one you're suggesting (https://github.com/plaid/sanctuary/blob/v0.4.0/index.js#L210-L221).
Nate Wildermuth
@wildermuthn
Feb 25 2015 17:49
      var accColumns = function(acc, value, index) {
        return R.appendTo(acc, makeColumn(value, index));
      };
^ Is there a way to make the above points free?
How would one go about breaking down this problem to find a points-free solution? Not sure where to begin.
David Chambers
@davidchambers
Feb 25 2015 17:53
You could, but I don't think you should. You'd probably need nthArg and converge.
Robin Lambertz
@roblabla
Feb 25 2015 18:17
@davidchambers @joneshf couldn't you do R.or(R.identity, R.identity) ?
David Chambers
@davidchambers
Feb 25 2015 18:40

We can't, actually:

> R.or(R.I, R.I)(false, true)
false

We're applying the result of evaluating R.or(R.I, R.I) to two arguments, but R.I ignores its second argument. Essentially we've written R.I(false) || R.I(false).

Raine Virta
@raine
Feb 25 2015 18:41
what kind of technique would be best for parsing "tokens" out of a string by some very simple rules?
maybe some type of recursive approach?
a vague question, i'm aware
Jethro Larson
@jethrolarson
Feb 25 2015 19:13
logicalOr = R.useWith(R.or, R.I, R.I)
Maybe there should be a ramda impl of normal || and &&, and the functional ones can be "either" and "both"
R.or = R.curry((a,b)=>a||b);
R.either = R.OldOr
R.eq doesn't take two functions, why should R.or?
Robin Lambertz
@roblabla
Feb 25 2015 19:18
I agree
Danny Fritz
@dannyfritz
Feb 25 2015 20:01
ramda on cdnjs is only at 0.8.0
Hardy Jones
@joneshf
Feb 25 2015 22:24
@jethrolarson +1
Jethro Larson
@jethrolarson
Feb 25 2015 22:35
Created #843
Robin Lambertz
@roblabla
Feb 25 2015 22:37
heh, the not one is tricky indeed.
Jethro Larson
@jethrolarson
Feb 25 2015 22:47

Also, I was reading #509 and I'm surprised that no one proposed callWith as an possible name for R.useWith. It has a very similar signature:

R.call(fn, a, b) == fn(a, b)
R.useWith(fn, fn2, fn3)(a, b) == fn(fn2(a), fn3(b))

I guess the big difference is that useWith always returns a function where call is immediate if supplied all its params.

Robin Lambertz
@roblabla
Feb 25 2015 22:49
bindWith would've made more sense than callWith IMO, since it doesn't actually immediately call the func
Jethro Larson
@jethrolarson
Feb 25 2015 23:01
Though should R.call(fn) actually call the function or return a partial that if supplied any parameters calls it?
Graeme Yeates
@megawac
Feb 25 2015 23:57
https://github.com/megawac/underscore/compare/restParams
What do you think @davidchambers @buzzdecafe
worth adding in R as well? (jsperf http://jsperf.com/trigger-with-for-loop-vs-slice/6)