Add sum function (#2653)
This commit is contained in:
parent
c6ff6939a5
commit
7959196dc7
6 changed files with 14 additions and 13 deletions
|
@ -21,3 +21,7 @@ export function erase<T>(x: T, xs: T[]): T[] {
|
|||
export function unique<T>(xs: T[]): T[] {
|
||||
return [...new Set(xs)];
|
||||
}
|
||||
|
||||
export function sum(xs: number[]): number {
|
||||
return xs.reduce((a, b) => a + b, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue