New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ntheq #3190
base: master
Are you sure you want to change the base?
Add ntheq #3190
Conversation
Thank you for a well-written, well-reasoned PR. I absolutely think we should unify index handling in I'm of two minds regarding adding more
But on the other side, we have the handling of negative indices. It makes no sense for const lifeline = {
'-3': 'parents met',
'-1': 'parents married',
0: 'birth',
18: 'graduated high school',
21: 'met future spouse',
22: 'graduated college',
24: 'married',
27: 'published first novel',
length: 28
}
prop (-1, lifeline) //=> '"published first novel", but expected "parents married" And this argues for keeping So I am torn. I would like to think about it and to hear arguments for and against. What do you think, @femioladipo ? And @ramda/core ? |
First off thanks I’m happy to contribute. Next, you raised some good points, and I agree with most. However, I've got a few suggestions. Give me to this afternoon to write something up. |
It is possible I haven't fully grasped the specifics of this proposal but as far as I can tell we could do something similar with pathEq([2], 'math', ['apple', '1A', 'math']);
//=> true
pathEq([-1], 'math', ['apple', '1A', 'math']);
//=> true |
But that's still a problem, as I'm concerned, all the |
Proposed
R.nth
R.equals
Reasoning
Sometimes users of
ramda
maybe have their data shaped in unusual ways due to constraints out of their control. They may then need to check if thenth
item in a list equals a given value. Currently, this can be achieved usingR.propEq(idx, val, list)
. However, this is less legible thanR.nthEq
. In addition, by the pure presence ofR.nth
whenR.prop
can handle indices and offsets (i.e. numbers) thenR.nthEq
should also be present.Finally, offset semantics are weirdly inconsistent in
R.propEq
when compared toR.prop
. For example: