aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorinoas <mail@inoas.com>2023-01-31 15:02:24 +0100
committerLouis Pilfold <louis@lpil.uk>2023-02-01 17:29:12 +0000
commit50862d1acc5c74fbf8de2b46f35c17c9a49057a4 (patch)
tree7c223d9114484c05293cb4286cafc089e55e2c9d /src
parent67e9cf8ea21ac829612e6e0ce2488c4748667a2a (diff)
downloadgleam_stdlib-50862d1acc5c74fbf8de2b46f35c17c9a49057a4.tar.gz
gleam_stdlib-50862d1acc5c74fbf8de2b46f35c17c9a49057a4.zip
product-of-empty-list-of-numbers-could-return-1
Diffstat (limited to 'src')
-rw-r--r--src/gleam/float.gleam2
-rw-r--r--src/gleam/int.gleam2
2 files changed, 2 insertions, 2 deletions
diff --git a/src/gleam/float.gleam b/src/gleam/float.gleam
index 5893b44..1ee175c 100644
--- a/src/gleam/float.gleam
+++ b/src/gleam/float.gleam
@@ -427,7 +427,7 @@ fn do_sum(numbers: List(Float), initial: Float) -> Float {
///
pub fn product(numbers: List(Float)) -> Float {
case numbers {
- [] -> 0.0
+ [] -> 1.0
_ -> do_product(numbers, 1.0)
}
}
diff --git a/src/gleam/int.gleam b/src/gleam/int.gleam
index eafbade..7623331 100644
--- a/src/gleam/int.gleam
+++ b/src/gleam/int.gleam
@@ -465,7 +465,7 @@ fn do_sum(numbers: List(Int), initial: Int) -> Int {
///
pub fn product(numbers: List(Int)) -> Int {
case numbers {
- [] -> 0
+ [] -> 1
_ -> do_product(numbers, 1)
}
}