Add sum function (#2653)

This commit is contained in:
Aya Morisawa
2018-09-07 04:21:04 +09:00
committed by syuilo
parent c6ff6939a5
commit 7959196dc7
6 changed files with 14 additions and 13 deletions

View File

@ -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);
}