These are chat archives for ramda/ramda

6th
Dec 2015
Jayson Harshbarger
@Hypercubed
Dec 06 2015 00:07
Actually this (http://ramdajs.com/0.17/manual/) is very good. Wish I saw it earlier.
Scott Sauyet
@CrossEye
Dec 06 2015 00:19
@Hypercubed: I'm glad you like it, but only the first few sections are completed. That's why we don't offer any links to it from anywhere yet.
Jayson Harshbarger
@Hypercubed
Dec 06 2015 01:29
@CrossEye Yes, I see that. The outline looks good anyway!
Sean Sartell
@ssartell
Dec 06 2015 02:58
Hey ramda folks! I'm learning ramda and point-free style programming via Advent of Code but I'm running into issues trying to use generators with ramda. Does ramda support generators?
Scott Sauyet
@CrossEye
Dec 06 2015 17:54
@ssartell: Ramda doesn't have any special facilities to deal with generators. What would it mean to you for it to support them?
Sean Sartell
@ssartell
Dec 06 2015 20:29
@CrossEye I'm not sure I understand what you mean by that? I was hoping the list functions (map, reduce, etc) would operate on any iterable object. The problem from day 3 requires finding the lowest positive integer that fits a certain condition and a generator seemed like the obvious choice, but no go.
Scott Sauyet
@CrossEye
Dec 06 2015 20:42

These will work with transducers. If we have this:

``````    var list = function*() {
yield 1;
yield 2;
yield 3;
};``````

Then, while this doesn't work:

``    R.map(R.inc, list());``

This should be fine:

``    R.into([], R.map(R.inc), list()); //=> [2, 3, 4]``
Hardy Jones
@joneshf
Dec 06 2015 21:05
I thought map was made to work on functions?
Scott Sauyet
@CrossEye
Dec 06 2015 21:10
`R.inc` is the increment function, `n => n + 1`. The second parameter can be a list -- for Ramda's internal call -- or anything matching the FantasyLand Functor spec (not really checked; if it has a `map` method we call it.) If you supply an iterable like this, and run it through the transducers side, it simply works as well. I would, in fact, like to get to the point where anything that accepts a list also accepts an arbitrary iterable. But we've done no work towards this as yet.
Hardy Jones
@joneshf
Dec 06 2015 21:21
wasn't it specialcased though?
Hardy Jones
@joneshf
Dec 06 2015 21:27
oh weird
``````> R.map(R.inc, () => 1)()
2
> R.map(R.inc, list)()
'1[object Generator]'``````
but
``````> Object.prototype.toString.call(list)
'[object Function]'``````
Scott Christopher
@scott-christopher
Dec 06 2015 21:43
`R.map` over a function is effectively compose.