Comments (7)
@selfrefactor I'm interested to find out how you would approach certain problems without the functionality of converge. If for instance I wanted to make sure that every element in an array of scores was an integer, I could write something like this in ramda:
const data = {
id: 'some_id',
scores: [0, '4', 10, 'hi']
}
const parseScores =
R.converge(
R.assoc,
[
R.always('scores'),
R.compose(
R.map(
R.when(
R.complement(R.is(Number)),
R.compose(
R.defaultTo(0),
parseInt
)
)
),
R.pathOr([], ['scores'])
),
R.identity
]
)
parseScores(data); // '{"id": "some_id", "scores": [0, 4, 10, 0]}'
The use of converge with assoc ensures that only the scores property is modified. How would you approach such a problem without the ability to converge?
from rambda.
Fair enough. I might create a PR in the near future, when I have some time.
Thanks!
from rambda.
Ok, that would be great. I will keep the issue open for the time being.
from rambda.
I left this types of method on purpose out of Rambda's API so there is no converge equivalent.
Rambda idea was to be used by people who find this types of methods as overkill.
Still, if you interested in creating PR with converge
method, I'll approve it.
from rambda.
I would go with more direct approach and leave FP behind in this case, i.e. I will write stupid explicit code.
from rambda.
+1, I don't understand how do you live without a kind of methods like converge.
Because of this I can't move from ramda to rambda =(
from rambda.
@MaxSvargal Sorry to hear that, but the PR with coverge
never arrived and that is why it is still missing in Rambda. As I said above, if PR with this method is submitted, I will gladly accept it.
As for your funny remark about living without converge
method - I find myself wanting to write stupider code as it is easier to maintain. converge
and other similar methods may be fun to use, but they require very specific mind approach, which not everybody are willing to agree with. We write code not only for our present self, but for our future self as well as for the people reading it. Smart code is great looking, but stupid code has its own beauty with its simpleness.
from rambda.
Related Issues (20)
- Is there any alternative to or plan to include __ placeholder function? HOT 1
- [Deno] mergeRight not found on import HOT 2
- Function Ramda.mergeDeepRight looses methods of target object HOT 1
- Doc issues HOT 8
- Upcoming tasks HOT 41
- `modifyPath` missing from 7.1.4 npm package HOT 3
- `mapObjIndex` cannot convert undefined or null to object HOT 4
- Predicate created by `anyPass` can't be used with array `.filter` HOT 4
- Webpack optimization bailout due to side effects in rambda.mjs HOT 14
- R.where short curcuiting HOT 3
- R.clone does not work with mongodb ObjectId HOT 3
- mergeDeepRight first parameter does not work with objects containing functions HOT 2
- New library that doesn't follow Ramda API HOT 14
- Bug: Unused generic type HOT 2
- TypeScript Error while using filter in pipe HOT 2
- Regression in rambda 7.4 HOT 12
- Unfair size comparison to ramda HOT 5
- yarn out doesn't work HOT 2
- types of path are breaking in 7.4.0 HOT 11
- omit doesn't preserve symbols HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rambda.