These are chat archives for ramda/ramda

12th
Sep 2018
Rocky Madden
@rockymadden
Sep 12 2018 13:47
If I understand, I typically use some something like an Either monad in these cases. When async, I use Fluture. Example sig: foo :: a -> Future a Error
Adrian Skierniewski
@AdrianSkierniewski
Sep 12 2018 15:06
Hi, I'm trying to write function that works exactly this some::string::with::colons => ['some', 'some::string', 'some::string::with'] Does anyone know how to do it? I've tried couple approaches but I feel that I'm missing some function call there.
Brad Compton (he/him)
@Bradcomp
Sep 12 2018 15:37
I would scheck out mapAccum or scan, one of those should help you out
Adrian Skierniewski
@AdrianSkierniewski
Sep 12 2018 15:37
I'm trying to use scan but it needs some initial value [ null, 'null::aggregates', 'null::aggregates::nested', 'null::aggregates::nested::name' ]
and then it adds it to all results
Brad Compton (he/him)
@Bradcomp
Sep 12 2018 15:41
here is an initial attempt I made with scan
Oh, I just saw you don't want the full value. You can add init to the beginning of the compose
compose(init, tail, scan(accumulator, ""), split("::"))("some::string::with::colons")
Adrian Skierniewski
@AdrianSkierniewski
Sep 12 2018 15:45
looking at it right now
@Bradcomp it works :) I completely missed the joinIfLeft and I tried to find some magic function inside ramda it self :)
Brad Compton (he/him)
@Bradcomp
Sep 12 2018 15:55
Here's another way that's sligntly less understandable, but has some nice properties in it: https://goo.gl/GuGhBF
Adrian Skierniewski
@AdrianSkierniewski
Sep 12 2018 16:05
Thank you :)
Brad Compton (he/him)
@Bradcomp
Sep 12 2018 16:05
:bowtie:
Pedro Ávila
@avilapedro
Sep 12 2018 22:07

This is the S combinator:

const S = f => g => x => f (x) (g(x))

In Ramda we can use ap as the S combinator.

But to me is very common that f first needs the result of g(x), and then x. Something like this:

const myCombinator = f => g => x => f (g(x)) (x)

Does myCombinator exists? What's his name? Does Ramda implement it?

Elias Cygnus
@eliascygnus
Sep 12 2018 22:17

how I can functionally populate array?

Like this, but in FP

const length = 20
const array = []

for (let i = 0; i < length; i++ {
    array.push(i)
}
Brad Compton (he/him)
@Bradcomp
Sep 12 2018 22:18
R.range