These are chat archives for ramda/ramda

23rd
Apr 2017
James Forbes
@JAForbes
Apr 23 2017 00:51

@Condell

just write the rest of the program using Ramda, then call the composed function inside of the get or post or whatever

That's what I do, I think its fine to be impure at the edge of your system (which express is).

Cody
@Condell
Apr 23 2017 00:52
@JAForbes Ok, thank you so much!
James Forbes
@JAForbes
Apr 23 2017 00:53
:+1:
Brad Compton (he/him)
@Bradcomp
Apr 23 2017 00:56
@Condell this was more of an experiment / learning exercise than anything, but it might be helpful.
Cody
@Condell
Apr 23 2017 01:05
@Bradcomp Awesome, thank you! I'm definitely going to dig into that because I know I'm going to have questions about writing to a db. I've never heard of sanctuary or fluture, but I'm guessing you use those opposed to ramda-fantasy? Is there any particular reason why? Or am I misunderstanding what those two libraries are for?
Brad Compton (he/him)
@Bradcomp
Apr 23 2017 01:12
Sanctuary is similar to Ramda, and provides type safe versions of Ramda functions, as well as a Maybe and Either type. Fluture is very similar to the R-F Future type, and it works well with Sanctuary.
Keep in mind both libraries have had breaking changes since that code was written
Cody
@Condell
Apr 23 2017 01:16
Ahhh, ok. Thank you for pointing that out! So basically there really isnt a need for IO since I can just use Future instead, for say an API call or writing to a db? I'm going off of what I read in Prof Frisby, so things might have changed since that was last updated haha.
Brad Compton (he/him)
@Bradcomp
Apr 23 2017 01:18
Yes, you can use Future as your monad in which you do the IO
Cody
@Condell
Apr 23 2017 01:20
@Bradcomp Ok, cool! Thank you! I'm so thankful to have you guys here to help. I spent hours googling, and then started reading about RxJS thinking that was the path to go down to deal with Express. But I'll just stick with Future for now.
Tushar Mathur
@tusharmath
Apr 23 2017 14:48

I need to write a program which returns the first set of consecutive numbers from a list

[0, 1, 2, 3, 6, 7] // [0, 1, 2, 3]
[2, 3, 4] // [2, 3, 4]
[5, 6, 7, 9, 10, 11] // [5, 6, 7]

What is the best possible way to solve this ?

Denis Stoyanov
@xgrommx
Apr 23 2017 15:19
@tusharmath map(nth(1))(takeWhile(([x, y]) => y - x === 1)(zip(a)(tail(a)))) + head of a
var a = [0, 1, 2, 3, 6, 7]
compose(prepend(head(a)), map(last), takeWhile(([x, y]) => y - x === 1), ap(zip, tail))(a)
Denis Stoyanov
@xgrommx
Apr 23 2017 15:25
point free version converge(prepend, [head, compose(map(last), takeWhile(([x, y]) => y - x === 1), ap(zip, tail))])(a)
full point free :smile: converge(prepend, [head, compose(map(last), takeWhile(compose(equals(-1), apply(subtract))), ap(zip, tail))])(a)
Tushar Mathur
@tusharmath
Apr 23 2017 15:40
@xgrommx I got the first one. Interesting approach.
BTW I have updated the documentation @xgrommxhttps://github.com/tusharmath/observable-air/blob/master/API.md
Denis Stoyanov
@xgrommx
Apr 23 2017 15:46
@tusharmath also u can check if it sorted like zipWith((x, y) => x < y)(a)(tail(a)) аnd fold it u can get true or false
Tushar Mathur
@tusharmath
Apr 23 2017 15:50
great thanks!
Denis Stoyanov
@xgrommx
Apr 23 2017 16:09
@tusharmath I forgot about reduceWhile reduceWhile((acc, x) => !(acc.length > 0 && x - last(acc) !== 1), (xs, x) => append(x, xs), [], [5,6,7,9,10,11])
@ram-bot reduceWhile((acc, x) => !(acc.length > 0 && x - last(acc) !== 1), (xs, x) => append(x, xs), [], [5,6,7,9,10,11])
ram-bot
@ram-bot
Apr 23 2017 16:09
[ 5, 6, 7 ]
Denis Stoyanov
@xgrommx
Apr 23 2017 16:09
@ram-bot reduceWhile((acc, x) => !(acc.length > 0 && x - last(acc) !== 1), (xs, x) => append(x, xs), [], [0, 1, 2, 3, 6, 7])
ram-bot
@ram-bot
Apr 23 2017 16:09
[ 0, 1, 2, 3 ]
Denis Stoyanov
@xgrommx
Apr 23 2017 16:14
@tusharmath reduceWhile((acc, x) => !(acc.length > 0 && x - last(acc) !== 1), flip(append), [], a)
Adam Recvlohe
@arecvlohe
Apr 23 2017 16:52
For those just learning Ramda like myself, you may find this helpful: https://medium.com/@arecvlohe/functional-programming-in-js-with-ramda-arrays-and-objects-468653f24d19
Denis Stoyanov
@xgrommx
Apr 23 2017 16:53
@arecvlohe for me no
Ryan Stegmann
@rstegg
Apr 23 2017 17:14
we don' take kindly to yer advertisin types
Brad Compton (he/him)
@Bradcomp
Apr 23 2017 17:17
@arecvlohe Cool!
Ryan Stegmann
@rstegg
Apr 23 2017 17:17
:smile:
Ryan Stegmann
@rstegg
Apr 23 2017 17:23
not very original, but good job!
Bravi
@Bravilogy
Apr 23 2017 17:39
greetings, devs!
if you know, is it possible to send push notifications to Android without using an app?
I couldn't find a good solution
yet
or actually, without developing an app
perhaps there's something already made out there
Ryan Stegmann
@rstegg
Apr 23 2017 20:59
has there been consideration of adding something like safeProp? or does something like this exist? (e.g. R.safeProp('x', undefined) // falsy)
Brad Compton (he/him)
@Bradcomp
Apr 23 2017 21:02
@ram-bot R.path(['x'], undefined)
ram-bot
@ram-bot
Apr 23 2017 21:02
undefined
Ryan Stegmann
@rstegg
Apr 23 2017 21:03
ty