mirror of
https://github.com/rjNemo/functional-programming-jargon
synced 2026-06-06 02:26:43 +00:00
adding ramda-extension
This commit is contained in:
parent
6fbf5252a2
commit
ffc2217e36
4 changed files with 1600 additions and 14 deletions
|
|
@ -3,5 +3,6 @@
|
|||
plugins: [markdown]
|
||||
rules:
|
||||
no-unused-vars: 0
|
||||
eqeqeq: 0
|
||||
no-undef: 0
|
||||
no-extend-native: 0
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
"eslint": "^6.6.0",
|
||||
"eslint-config-standard": "^6.0.0",
|
||||
"eslint-plugin-markdown": "^1.0.0-beta.6",
|
||||
"eslint-plugin-promise": "^4.2.1",
|
||||
"eslint-plugin-standard": "^3.0.1",
|
||||
"pre-commit": "^1.2.2",
|
||||
"roadmarks": "^1.6.3"
|
||||
|
|
|
|||
18
readme.md
18
readme.md
|
|
@ -115,9 +115,9 @@ ie. they allow referencing a scope after the block in which the variables were d
|
|||
|
||||
|
||||
```js
|
||||
const addTo = x => y => x + y;
|
||||
var addToFive = addTo(5);
|
||||
addToFive(3); //returns 8
|
||||
const addTo = x => y => x + y
|
||||
var addToFive = addTo(5)
|
||||
addToFive(3) // returns 8
|
||||
```
|
||||
The function ```addTo()``` returns a function(internally called ```add()```), lets store it in a variable called ```addToFive``` with a curried call having parameter 5.
|
||||
|
||||
|
|
@ -704,7 +704,7 @@ A homomorphism is just a structure preserving map. In fact, a functor is just a
|
|||
```js
|
||||
A.of(f).ap(A.of(x)) == A.of(f(x))
|
||||
|
||||
Either.of(_.toUpper).ap(Either.of("oreos")) == Either.of(_.toUpper("oreos"))
|
||||
Either.of(_.toUpper).ap(Either.of('oreos')) == Either.of(_.toUpper('oreos'))
|
||||
```
|
||||
|
||||
### Catamorphism
|
||||
|
|
@ -724,8 +724,8 @@ An `unfold` function. An `unfold` is the opposite of `fold` (`reduce`). It gener
|
|||
```js
|
||||
const unfold = (f, seed) => {
|
||||
function go (f, seed, acc) {
|
||||
const res = f(seed);
|
||||
return res ? go(f, res[1], acc.concat([res[0]])) : acc;
|
||||
const res = f(seed)
|
||||
return res ? go(f, res[1], acc.concat([res[0]])) : acc
|
||||
}
|
||||
return go(f, seed, [])
|
||||
}
|
||||
|
|
@ -753,8 +753,7 @@ In paramorphism, your reducer's arguments are the current value, the reduction o
|
|||
// Obviously not safe for lists containing `undefined`,
|
||||
// but good enough to make the point.
|
||||
const para = (reducer, accumulator, elements) => {
|
||||
if (elements.length === 0)
|
||||
return accumulator
|
||||
if (elements.length === 0) { return accumulator }
|
||||
|
||||
const head = elements[0]
|
||||
const tail = elements.slice(1)
|
||||
|
|
@ -991,7 +990,7 @@ A **function** `f :: A => B` is an expression - often called arrow or lambda exp
|
|||
|
||||
```js
|
||||
// times2 :: Number -> Number
|
||||
const times2 = n => n * 2
|
||||
const times2 = n => n * 2;
|
||||
|
||||
[1, 2, 3].map(times2) // [2, 4, 6]
|
||||
```
|
||||
|
|
@ -1069,6 +1068,7 @@ Making your partial functions total ones, these kinds of runtime errors can be p
|
|||
* [Immer](https://github.com/mweststrate/immer)
|
||||
* [Ramda](https://github.com/ramda/ramda)
|
||||
* [ramda-adjunct](https://github.com/char0n/ramda-adjunct)
|
||||
* [ramda-extension](https://github.com/tommmyy/ramda-extension)
|
||||
* [Folktale](http://folktale.origamitower.com/)
|
||||
* [monet.js](https://cwmyers.github.io/monet.js/)
|
||||
* [lodash](https://github.com/lodash/lodash)
|
||||
|
|
|
|||
Loading…
Reference in a new issue