These are chat archives for ramda/ramda

28th
Jun 2015
Raine Virta
@raine
Jun 28 2015 00:48
gilligan: what's accu? aren't you supposed to set to result?
Scott Christopher
@scott-christopher
Jun 28 2015 00:49
As @raine mentioned, it looks like your example is incomplete.
var t = obj => R.pipe(
  R.prop('fragments'),
  R.toPairs,
  R.map(R.adjust(R.replace(obj.typ + '.', ''), 0)),
  R.fromPairs
)(obj);

t({ typ: 'thing', fragments: {
  'thing.foo': 'bar',
  'thing.baz': 'thang'
}}) // {"baz": "thang", "foo": "bar"}
oh I forgot about adjust
Tobias Pflug
@gilligan
Jun 28 2015 05:59
@raine thanks
Aldwin Vlasblom
@Avaq
Jun 28 2015 08:55

Hi! Can someone explain transduce to me? I don't see the added value of transduce in the example given in the documentation:

var numbers = [1, 2, 3, 4];
var transducer = R.compose(R.map(R.add(1)), R.take(2));

R.transduce(transducer, R.flip(R.append), [], numbers); //=> [2, 3]

Because just doing:

transducer(numbers); //=> [2, 3]

Without an example showing me why it's useful I find it a very difficult function to grasp. :|

Scott Christopher
@scott-christopher
Jun 28 2015 09:12
@Avaq: this article may help your understanding http://simplectic.com/blog/2015/ramda-transducers-logs/
Aldwin Vlasblom
@Avaq
Jun 28 2015 09:16
@scott-christopher Thanks! I'll read that. :)
Aldwin Vlasblom
@Avaq
Jun 28 2015 09:39
@scott-christopher Oh there's a whole world of stuff to read about transducers. I didn't realize that it's not something specific to Ramda :$. I'm just getting into functional programming with Ramda being my starting point. :)
Scott Christopher
@scott-christopher
Jun 28 2015 09:40
To be completely honest, I still haven't played much with transducers yet either.
They're useful in a streaming context by being able to use all the familiar functions like map and filter without building intermediate lists in between.
Aldwin Vlasblom
@Avaq
Jun 28 2015 09:45
Right, they seem to go hand in hand with functional programming in that regard. It seems like Clojure brought them into existence.
Ohh! A transducer passes a single value through the whole pipeline before moving onto the next, whereas a standard pipeline of functions operating on an array operates function-by-function, passing all values in every time and building intermediate arrays! (?)
these helped me
Aldwin Vlasblom
@Avaq
Jun 28 2015 09:51
@raine Thanks