These are chat archives for ramda/ramda

8th
Feb 2018
Jonathan Chang
@jdkschang
Feb 08 2018 01:10
Are there any advantages to R.partial compared to R.curry ?
R.curry feels way more flexible and forgiving—especially when certain conditions haven’t been met
Gant Laborde
@GantMan
Feb 08 2018 14:40
I have a buddy who wrote this code
const _avatarArray = [
  {profile_uuid: 1},
  {profile_uuid: 2}
]

R.find(R.propEq('profile_uuid', 3), _avatarArray) === undefined
I'd like to improve it, but I'm not seeing how... it feels far too wordy. Thoughts?
This will end up in an if statement
Mike Lambert
@lax4mike
Feb 08 2018 14:51
that looks fine to me
if you want to reuse it:
const containsUUID = R.curry((id, array) => R.compose(
  R.complement(R.isNil),
  R.find(R.propEq('profile_uuid', id))
)(array));
const result = containsUUID(3, _avatarArray);
Gant Laborde
@GantMan
Feb 08 2018 15:09
cool! thanks
Tomáš Konrády
@tommmyy
Feb 08 2018 15:58
const _avatarArray = [
  {profile_uuid: 1},
  {profile_uuid: 2}
]

const fn = R.useWith(R.none, [R.propEq('profile_uuid'), R.identity]);

fn(3, _avatarArray)
@GantMan
Mike Lambert
@lax4mike
Feb 08 2018 16:01
why do you need R.identity?
can you just do this?
const result = R.none(R.propEq("profile_uuid", 3))(_avatarArray)
Tomáš Konrády
@tommmyy
Feb 08 2018 16:03
just for readability. arity is more explicit.
and your version is not reusable for custom id
Mike Lambert
@lax4mike
Feb 08 2018 16:05
oh, i see how that works
i haven't really used R.useWith
Tomáš Konrády
@tommmyy
Feb 08 2018 16:06
@lax4mike than I recommend to checkout R.juxt and R.converge
Vasili Sviridov
@vsviridov
Feb 08 2018 17:46
why not just uuid => R.any(R.propEq('profile_uuid', uuid))?
Will Farley
@goldhand
Feb 08 2018 21:16
My brain is hurting trying to figure out if there is a better way to do this:
const reduceSource = R.curry((fn, acc, arr) =>R. reduce(R.partialRight(fn, [acc]), acc, arr));
I’m wondering if there is a more idomatic way to modify a functions argument, in the way I am in the above example.