These are chat archives for ramda/ramda

13th
Oct 2015
boxofrox
@boxofrox
Oct 13 2015 00:14
If i have a list of unary functions [fn, fn, fn], is there a Ramda function to invoke each function with its respective value from an input array [1, 2, 3]?
I think the type signature would be [f] -> [a] -> [f a], but R.ap will run each fn three times with the given input array.
Jethro Larson
@jethrolarson
Oct 13 2015 00:17
Is that like zipWith(apply)
Er zipWith(call)
boxofrox
@boxofrox
Oct 13 2015 00:19
yea, that would do it. thanks @jethrolarson
Raine Virta
@raine
Oct 13 2015 07:50
it would be cool if ramda-cli could filter a stream of objects
because right now you have to --slurp to make the input an array
maybe transducers could help there
Vladimir Starkov
@iamstarkov
Oct 13 2015 09:01
@joneshf this stuff is working now
var R = require('ramda');
var mergeConcat = (x, y) => R.reduce((acc, kv) => R.over(R.lensProp(kv[0]), R.pipe(R.defaultTo([]), R.concat(R.__, kv[1])), acc), x, R.toPairs(y) );
> mergeConcat({ list: ['asd']}, { list: [1, 2,3] });
{ list: [ 'asd', 1, 2, 3 ] }
Niloy Mondal
@niloy
Oct 13 2015 09:53
Is R.bind just an alias to R.partial?
Raine Virta
@raine
Oct 13 2015 09:53
no
they do different things
Niloy Mondal
@niloy
Oct 13 2015 10:00
Yeh I guess, am not able to figure out the difference. R.bind has minimal doc, no example.
Raine Virta
@raine
Oct 13 2015 10:01

it's same as regular .bind except for

Note: R.bind does not provide the additional argument-binding capabilities of Function.prototype.bind.

R.bind(fn, obj) == fn.bind(obj)
Niloy Mondal
@niloy
Oct 13 2015 10:03
Oh I see, it only binds this, which is weird in a functional programming library
Scott Sauyet
@CrossEye
Oct 13 2015 10:34
It is odd, but it does make it easier to interoperate with systems written in an OO fashion. Even console.log needs it in some environments.
Niloy Mondal
@niloy
Oct 13 2015 10:36
👍
Hardy Jones
@joneshf
Oct 13 2015 13:54
@boxofrox ap is what you wanted, if you're willing to change the data type. zipWith does it ad-hoc-ly as well, as @jethrolarson pointed out.
@iamstarkov cool, shame it requires so much boilerplate though.
@iamstarkov maybe we can poke @CrossEye a few times to rekindle the conversation.
:)
Hardy Jones
@joneshf
Oct 13 2015 14:18
undefined (undefined@irc.gitter.im) has left #ramda/ramda
That's a good sign.
Dave Keen
@ccapndave
Oct 13 2015 17:01
Hey everyone - I want to make a function that turns function arguments into named properties on objects - (a, b, c) => ({ a, b, c }). Is there a Ramda function that can help me do this?
Martin Algesten
@algesten
Oct 13 2015 17:02
you can't really get an enumeration of the function param names though?
at least i don't think you can in javascript?
Dave Keen
@ccapndave
Oct 13 2015 17:03
I don't mind specifying them
Its for the selector function of an Rx combineLatest, so maybe there is something like Rx.Observable.combineLatest(a$, b$, c$, R.blah('a', 'b', 'c'));
David Chambers
@davidchambers
Oct 13 2015 17:05
> R.curryN(3, R.unapply(R.zipObj(['a', 'b', 'c'])))(1)(2)(3)
{ a: 1, b: 2, c: 3 }
Dave Keen
@ccapndave
Oct 13 2015 17:05
Oh dear
David Chambers
@davidchambers
Oct 13 2015 17:05
If currying is not required:
> R.unapply(R.zipObj(['a', 'b', 'c']))(1, 2, 3)
{ a: 1, b: 2, c: 3 }
Dave Keen
@ccapndave
Oct 13 2015 17:05
That's not the Ramda clarity I'm looking for :)
(a, b, c) => ({ a, b, c }) is clearer in that case
David Chambers
@davidchambers
Oct 13 2015 17:06
If you took the arguments as a list rather than as positional arguments, you could write:
> R.zipObj(['a', 'b', 'c'])([1, 2, 3])
{ a: 1, b: 2, c: 3 }

(a, b, c) => ({ a, b, c }) is clearer in that case

I agree. I would stick with that if it's syntactically valid.

Dave Keen
@ccapndave
Oct 13 2015 17:07
I'll see if I can wrap up a nary version in a higher order function
It would be quite useful
Denis Stoyanov
@xgrommx
Oct 13 2015 17:09
Dave Keen
@ccapndave
Oct 13 2015 17:10
That's an extremely good point
Especially since I asked @staltz to write this in the first place
(And then forgot about it)
Much better
joneshf-work1
@joneshf-work1
Oct 13 2015 20:03
@iamstarkov guess who needs that exact function right now? :)