These are chat archives for ramda/ramda

13th
Aug 2016
Rick Medina
@rickmed
Aug 13 2016 00:12
@rpominov are you using any particular editor for typescript?
Michael Hurley
@buzzdecafe
Aug 13 2016 00:21
Rick Medina
@rickmed
Aug 13 2016 00:26
@rpominov sorry wrong mention
Rick Medina
@rickmed
Aug 13 2016 00:51
is there a better way vs R.reduce(R.uncurryN(2, R.add), 0)
mmm maybe that's way sum exists
Michael Hurley
@buzzdecafe
Aug 13 2016 00:55
uncurryN is not doing anything for you @rickmed
reduce(add, 0) will do, or as you pointed out, sum
Rick Medina
@rickmed
Aug 13 2016 00:56
is not working without uncurry
Michael Hurley
@buzzdecafe
Aug 13 2016 00:57
i guess that depends what you mean by "working". http://goo.gl/T7nDYW
note the implementation of sum
Rick Medina
@rickmed
Aug 13 2016 00:59
scratch that
it worked
Michael Hurley
@buzzdecafe
Aug 13 2016 00:59
:-)
Rick Medina
@rickmed
Aug 13 2016 00:59
weird, it does not work with tyscript
Michael Hurley
@buzzdecafe
Aug 13 2016 00:59
can't help you there
Rick Medina
@rickmed
Aug 13 2016 01:00
:)
reduce is expecting a 2 arity fn but add is curried? how does that work?
@buzzdecafe sorry for all the newbie questions
Michael Hurley
@buzzdecafe
Aug 13 2016 01:02
no worries; ramda started as a learning project.
so ... note that R.add.length == 2
and R.add(1).length == 1
ramda curry is a little less pure than real curry
R.add(1, 2) == R.add(1)(2)
so when you pass add to reduce, it is evaluated as add(acc, x)
Rick Medina
@rickmed
Aug 13 2016 01:07
does it work like that with all ramda's equivalent functions? why is it not completely pure?
Michael Hurley
@buzzdecafe
Aug 13 2016 01:12
  1. Yes, all R functions are curried in this way.
  2. By pure, I mean that curry is often defined as transforming a function of n arguments into n functions of one argument. ramda curry is looser, so you can:
const f = curry((a, b, c) => a + b + c);
// the following produce equivalent results:
f(1, 2, 3);
f(1)(2, 3);
f(1, 2)(3);
f(1)(2)(3);
Rick Medina
@rickmed
Aug 13 2016 01:13
I looked at the source code
right, returns a different type of fn depending on how arguments are passed
so yeah is not as pure as returning just the curried version
i guess to be able to do what you just described...
it's cool (although a bit confusing)
thank you! @buzzdecafe
Michael Hurley
@buzzdecafe
Aug 13 2016 01:15
u r welcome
Roman Pominov
@rpominov
Aug 13 2016 08:11
@buzzdecafe finally someone have appreciated the joke :smile: