These are chat archives for ramda/ramda

2nd
Apr 2018
Scott Sauyet
@CrossEye
Apr 02 2018 03:28
@Undistraction: This seems simpler to me. But it's not well-tested:
const moveItem = curry((oldIndex, newIndex, arr) =>
  insert(newIndex, arr[oldIndex], remove(oldIndex, 1, arr))
)
Pedr Browne
@Undistraction
Apr 02 2018 07:43
@CrossEye Nice. Definitely simpler, but less readable imho.
Luca Matteis
@lmatteis
Apr 02 2018 11:19
hello!
i have an hasApples(data) function which returns a boolean. sometimes i need to use it along a pipe and i do pipe(foo, hasApples, bar) and it's all good. however when i need to check whether there are no apples i do pipe(foo, data => !hasApples(data), bar) which is rather ugly. any ideas?
James Forbes
@JAForbes
Apr 02 2018 11:31
alternatively when(hasApples, bar)
Luca Matteis
@lmatteis
Apr 02 2018 11:32
thanks!
even though complement(hasApples) isn't really readable. i would expect not(hasApples) to work better
James Forbes
@JAForbes
Apr 02 2018 11:46
Yeah I understand that perspective, think of not as a function alternative to !
so not( true ) //=> false but complement( () => true ) //=> false
there's plenty of functions in ramda that act as alternatives to standard operators, like add, subtract, divide, multiply, not, modulo, assoc, or, and etc
just as we've got not and complement we've got similar scenarios with both and and, or either and or. Functions that operate on values vs functions that operate on functions.
Luca Matteis
@lmatteis
Apr 02 2018 11:50
i see
Vesa Karvonen
@polytypic
Apr 02 2018 12:05
pipe(foo, hasApples, not, bar)
Luca Matteis
@lmatteis
Apr 02 2018 12:11
ah right i could do that too thanks @polytypic
Mike Lambert
@lax4mike
Apr 02 2018 12:27
You can also define a new function const doesntHaveApples = R.complement(hasApples)
Scott Sauyet
@CrossEye
Apr 02 2018 12:32
I never liked changing not, and, and orinto complement, both, and either. I had no counter-argument to the suggestion that those names were better-suited for the functions acting as replacements for the built-in operators. But I'm still unhappy about it.
Pedr Browne
@Undistraction
Apr 02 2018 14:06
Yep. From what I've seen the naming of these functions are a big source of confusion. For improved readability we offer
Mike Lambert
@lax4mike
Apr 02 2018 14:28
@CrossEye what would R.not be named if R.compliment was named R.not?
Brad Compton (he/him)
@Bradcomp
Apr 02 2018 19:21
Probably just R.bang ;)
Mike Lambert
@lax4mike
Apr 02 2018 19:44
i like it! :thumbsup: