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]
|
plugins: [markdown]
|
||||||
rules:
|
rules:
|
||||||
no-unused-vars: 0
|
no-unused-vars: 0
|
||||||
|
eqeqeq: 0
|
||||||
no-undef: 0
|
no-undef: 0
|
||||||
no-extend-native: 0
|
no-extend-native: 0
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
"eslint": "^6.6.0",
|
"eslint": "^6.6.0",
|
||||||
"eslint-config-standard": "^6.0.0",
|
"eslint-config-standard": "^6.0.0",
|
||||||
"eslint-plugin-markdown": "^1.0.0-beta.6",
|
"eslint-plugin-markdown": "^1.0.0-beta.6",
|
||||||
|
"eslint-plugin-promise": "^4.2.1",
|
||||||
"eslint-plugin-standard": "^3.0.1",
|
"eslint-plugin-standard": "^3.0.1",
|
||||||
"pre-commit": "^1.2.2",
|
"pre-commit": "^1.2.2",
|
||||||
"roadmarks": "^1.6.3"
|
"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
|
```js
|
||||||
const addTo = x => y => x + y;
|
const addTo = x => y => x + y
|
||||||
var addToFive = addTo(5);
|
var addToFive = addTo(5)
|
||||||
addToFive(3); //returns 8
|
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.
|
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
|
```js
|
||||||
A.of(f).ap(A.of(x)) == A.of(f(x))
|
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
|
### Catamorphism
|
||||||
|
|
@ -724,8 +724,8 @@ An `unfold` function. An `unfold` is the opposite of `fold` (`reduce`). It gener
|
||||||
```js
|
```js
|
||||||
const unfold = (f, seed) => {
|
const unfold = (f, seed) => {
|
||||||
function go (f, seed, acc) {
|
function go (f, seed, acc) {
|
||||||
const res = f(seed);
|
const res = f(seed)
|
||||||
return res ? go(f, res[1], acc.concat([res[0]])) : acc;
|
return res ? go(f, res[1], acc.concat([res[0]])) : acc
|
||||||
}
|
}
|
||||||
return go(f, seed, [])
|
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`,
|
// Obviously not safe for lists containing `undefined`,
|
||||||
// but good enough to make the point.
|
// but good enough to make the point.
|
||||||
const para = (reducer, accumulator, elements) => {
|
const para = (reducer, accumulator, elements) => {
|
||||||
if (elements.length === 0)
|
if (elements.length === 0) { return accumulator }
|
||||||
return accumulator
|
|
||||||
|
|
||||||
const head = elements[0]
|
const head = elements[0]
|
||||||
const tail = elements.slice(1)
|
const tail = elements.slice(1)
|
||||||
|
|
@ -991,7 +990,7 @@ A **function** `f :: A => B` is an expression - often called arrow or lambda exp
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// times2 :: Number -> Number
|
// times2 :: Number -> Number
|
||||||
const times2 = n => n * 2
|
const times2 = n => n * 2;
|
||||||
|
|
||||||
[1, 2, 3].map(times2) // [2, 4, 6]
|
[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)
|
* [Immer](https://github.com/mweststrate/immer)
|
||||||
* [Ramda](https://github.com/ramda/ramda)
|
* [Ramda](https://github.com/ramda/ramda)
|
||||||
* [ramda-adjunct](https://github.com/char0n/ramda-adjunct)
|
* [ramda-adjunct](https://github.com/char0n/ramda-adjunct)
|
||||||
|
* [ramda-extension](https://github.com/tommmyy/ramda-extension)
|
||||||
* [Folktale](http://folktale.origamitower.com/)
|
* [Folktale](http://folktale.origamitower.com/)
|
||||||
* [monet.js](https://cwmyers.github.io/monet.js/)
|
* [monet.js](https://cwmyers.github.io/monet.js/)
|
||||||
* [lodash](https://github.com/lodash/lodash)
|
* [lodash](https://github.com/lodash/lodash)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue