R.cond is a mess!
See original GitHub issueR.cond returns a function, why? It doesn’t make any sense.
What is more primitive, a function that resolves on invocation, or one that always returns a function? I want to simply be able to do this:
const address = R.cond([
[email.to && email.to.includes(search), email.to],
[email.cc && email.cc.includes(search), email.cc],
[email.bcc && email.bcc.includes(search), email.bcc],
]);
It doesn’t work! Because it returns a function.
You’re example in the docs is this:
var fn = R.cond([
[R.equals(0), R.always('water freezes at 0°C')],
[R.equals(100), R.always('water boils at 100°C')],
[R.T, temp => 'nothing special happens at ' + temp + '°C']
]);
fn(0); //=> 'water freezes at 0°C'
fn(50); //=> 'nothing special happens at 50°C'
fn(100); //=> 'water boils at 100°C'
However, if you wrote the cond how I’m suggesting, it would look like this, which is even more readable! and it allows cond
to work more generally on more use cases:
var fn = (x) => R.cond([
[x === 0 , 'water freezes at 0°C'],
[x === 100, 'water boils at 100°C'],
[true, 'nothing special happens at ' + x + '°C']
]);
fn(0); //=> 'water freezes at 0°C'
fn(50); //=> 'nothing special happens at 50°C'
fn(100); //=> 'water boils at 100°C'
The way it is right now, how many people actual use cond
, probably very few. I would recommend not using it and avoiding it even.
I really like Ramda, but I think you screwed up with this one, thank you.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:25
- Comments:21 (14 by maintainers)
Top Results From Across the Web
MESS.pdf
Description A mixed collection of useful and semi-useful diverse statistical functions, some of which may even be referenced in. The R Primer book....
Read more >5 Dealing with messy data | Modern Statistics with R
When variables of different types are somehow combined (with addition, put in the same vector, and so on), R will coerce both to...
Read more >cleaning a messy character column in R - Stack Overflow
We create a logical condition, i.e. if the length of the index is greater than 0, we return the element corresponding to 'x1'...
Read more >launch is a mess... : r/DarkTide - Reddit
r /spotted - Insane [Volvo TP21 'Sugga'] spotted in London. ... Power Supply Interruption (lights out) is the best special condition.
Read more >How to use the R case_when function - Sharp Sight
Inside the parenthesis of case_when, the left hand side is a conditional statement that should evaluate as TRUE or FALSE . This condition...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This thread contains several unsubstantiated claims which sound to me very much like personal sentiments. For example:
It’s clear that you care a great deal about Ramda @decoursin, which is wonderful. Everyone involved in this discussion cares a great deal about Ramda. My suggestion to you is that you consider the tone with which you convey your ideas. I welcome disagreement, but prefer people to disagree with me in a friendly manner. 😃
i’m good with it