mirror of
https://github.com/rjNemo/functional-programming-jargon
synced 2026-06-06 02:26:43 +00:00
fix partial function sum example
This commit is contained in:
parent
ca37a0e6d4
commit
7f6f412552
1 changed files with 2 additions and 2 deletions
|
|
@ -926,7 +926,7 @@ A partial function is a [function](#function) which is not defined for all argum
|
|||
// sum :: [Number] -> Number
|
||||
const sum = arr => arr.reduce((a, b) => a + b)
|
||||
sum([1, 2, 3]) // 6
|
||||
sqrt([]) // TypeError: Reduce of empty array with no initial value
|
||||
sum([]) // TypeError: Reduce of empty array with no initial value
|
||||
|
||||
// example 2: get the first item in list
|
||||
// first :: [A] -> A
|
||||
|
|
@ -957,7 +957,7 @@ Fortunately a partial function can be converted to a regular (or total) one. We
|
|||
// sum :: [Number] -> Number
|
||||
const sum = arr => arr.reduce((a, b) => a + b, 0)
|
||||
sum([1, 2, 3]) // 6
|
||||
sqrt([]) // 0
|
||||
sum([]) // 0
|
||||
|
||||
// example 2: get the first item in list
|
||||
// change result to Option
|
||||
|
|
|
|||
Loading…
Reference in a new issue