These are chat archives for ramda/ramda

20th
Oct 2017
Ashish Gupta
@gotoashishgupta
Oct 20 2017 04:44
any help in how to make liftpaths completely point-free would be great
YarnBall
@yarnball
Oct 20 2017 07:57
Hi all, I'm still really struggling with this ramda- https://tinyurl.com/ya7dff4f
I've given my desired output at the bottom. Basically I want to give structure to some flat data, given the integer it has
My attempt is close, but pipe( prop('type'), find(pipe(prop('level'), equals(1))), propOr('NoName', 'name'), ), that's only returning the first item it fiels with equals(1). I want it to repeat that for all equals(1) it finds
Michael Hurley
@buzzdecafe
Oct 20 2017 12:07
without looking closely, "I want it to repeat that for all equals(1) it finds" sounds more like filter than find
arian‮
@arian-swydo
Oct 20 2017 14:25
hey guys, this is probably the dumbest thing you've seen, but I was wondering why I cant make the following function point free: https://goo.gl/dFGVbi
I know this is absolutely not how to write this, it's meant as a joke, but I stumbled on this weird situation I can't explain
Vesa Karvonen
@polytypic
Oct 20 2017 14:46
The reason is immediate recursion to fib.
arian‮
@arian-swydo
Oct 20 2017 15:42
why would it be immediate? isn't it wrapped in an o composition?
Vesa Karvonen
@polytypic
Oct 20 2017 16:02
What you essentially have is const x = f(x). When evaluating the right hand side, f(x), the value of x is not defined. It is unfortunate that JavaScript allows you to write a definition like that without an error.
arian‮
@arian-swydo
Oct 20 2017 16:13
but isn't const f = n => o(...)(...)(n) the same as const f = o(...)(...)
the not commented out line works, but the commented one, which I understand to be the same without declaring arguments, does not work:
  n => o (o(apply(add))(flip(map)(times(inc,2)))) (o(o(fib))(subtract)) (n)
  //   o (o(apply(add))(flip(map)(times(inc,2)))) (o(o(fib))(subtract))
maybe it's something to with map
?
arian‮
@arian-swydo
Oct 20 2017 16:27
hmmm I think I see what you mean
@polytypic :) thanks
Achilleas Naoumidis
@anaumidis
Oct 20 2017 17:17
Hello! Have you thought about dispatching chain and map to then aslo, if present?
Brad Compton (he/him)
@Bradcomp
Oct 20 2017 17:21
It's been mentioned before. There have been a number of discussions in the issues as to what the extent of dispatching should be :)
@arian-swydo Due to Javascript's eager evaluation model, you can't make a recursive function point free. The right side gets evaluated, then assigned to the left. Because of this, fib is undefined when passed to o(o(fib)) on line 7. By wrapping in a lambda (n => ...) you delay the evaluation of fib until the function gets invoked, which occurs after fib is defined.
arian‮
@arian-swydo
Oct 20 2017 18:27
thanks brad, should've been painfully obvious, but wasn't :smile:
arian‮
@arian-swydo
Oct 20 2017 18:36
does anyone know where 'o' comes from and what it stands for?
Brad Compton (he/him)
@Bradcomp
Oct 20 2017 19:09
It's similar to the mathematical symbol for function composition
Vesa Karvonen
@polytypic
Oct 20 2017 19:29
(The Standard ML Basis Library defines o as infix operator for function composition.)
Michael Hurley
@buzzdecafe
Oct 20 2017 20:21
@polytypic I did not realize that! TIL
arian‮
@arian-swydo
Oct 20 2017 21:39
thanks guys