These are chat archives for ramda/ramda

9th
Apr 2018
Mike Lambert
@lax4mike
Apr 09 2018 13:52
you can do this though R.juxt([x => x * 10, x => x * 20])(2)
Denis Stoyanov
@xgrommx
Apr 09 2018 14:14
I know, that isn't new for me
Sean Cannon
@SeanCannon
Apr 09 2018 16:26
@lax4mike most of the Ramda functions predate es6. Lots of Ramda functions don't have as much impact in a ES6 project. clone, curry, assoc, etc. a => b => c => {} feels much more intuitive than R.curry((a,b,c) => {}) even if Ramda auto-curries. You can get your own auto-curry in a es6 one-liner : const curry = (fn, ...args) => args.length === fn.length ? fn(...args) : curry.bind(null, fn, ...args);
Mike Lambert
@lax4mike
Apr 09 2018 18:03
The problem with arrow functions as a replacement for currying is that you are forced to provide the arguments one at a time, eg const add = a => b => a + b needs to be invoked with the weird butt syntax add(2)(3) // 5
Sean Cannon
@SeanCannon
Apr 09 2018 18:04
That's not a problem, it's just different syntax. Think Haskell. It's about as declarative as you can get.
i forgot to take note
on top of it i would like to generate ids based on the field
so [3:{"a1"}, {44:"b1"}]
Sean Cannon
@SeanCannon
Apr 09 2018 22:19
[3:{"a1"}, {44:"b1"}] isn't actual JS. Do you mean [{3:"a1"}, {44:"b1"}] ?
Lewis
@6ewis
Apr 09 2018 22:20
yes
obviously
Sean Cannon
@SeanCannon
Apr 09 2018 22:20
so given this {guide: { a: {a1: "a1"}, b:{b1: "b1"}, c:{c1: "c1"} }} what is the output you expect
Lewis
@6ewis
Apr 09 2018 22:21
[{A:"a1"}, {B:"b1"}] , with A and B being uniquetly identifiable ID (a digit)
Sean Cannon
@SeanCannon
Apr 09 2018 22:22
just any digit
why type A and B if you want a digit?
Lewis
@6ewis
Apr 09 2018 22:24
omg,
Sean Cannon
@SeanCannon
Apr 09 2018 22:33
omg indeed, Lewis. o.m.g.
Just add R.map(a => ({ [a.charCodeAt()] : a })), as your first line
you can swap that id maker with anything
Sean Cannon
@SeanCannon
Apr 09 2018 22:44
Or overly-complicate it with Ramda R.map(a => R.compose(R.objOf(R.__, a), R.invoker(0, 'charCodeAt'))(a)),