mirror of
https://github.com/rjNemo/functional-programming-jargon
synced 2026-06-12 05:26:43 +00:00
Update monad example (#115)
Monad description mentions 'of' function; update the example to use this.
This commit is contained in:
parent
52b9f361b6
commit
e918b396ec
1 changed files with 2 additions and 2 deletions
|
|
@ -488,10 +488,10 @@ Array.prototype.chain = function (f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Usage
|
// Usage
|
||||||
;['cat,dog', 'fish,bird'].chain((a) => a.split(',')) // ['cat', 'dog', 'fish', 'bird']
|
;Array.of('cat,dog', 'fish,bird').chain((a) => a.split(',')) // ['cat', 'dog', 'fish', 'bird']
|
||||||
|
|
||||||
// Contrast to map
|
// Contrast to map
|
||||||
;['cat,dog', 'fish,bird'].map((a) => a.split(',')) // [['cat', 'dog'], ['fish', 'bird']]
|
;Array.of('cat,dog', 'fish,bird').map((a) => a.split(',')) // [['cat', 'dog'], ['fish', 'bird']]
|
||||||
```
|
```
|
||||||
|
|
||||||
`of` is also known as `return` in other functional languages.
|
`of` is also known as `return` in other functional languages.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue