From 309088e5d2e38153d136c4d1d57392ebf62f0d96 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Mon, 4 Dec 2023 15:13:48 +0100 Subject: [PATCH] part 1 task 0 --- Lab11.iml | 12 ++++++++++++ src/TestArray.scala | 9 +++++++++ 2 files changed, 21 insertions(+) create mode 100644 Lab11.iml create mode 100644 src/TestArray.scala diff --git a/Lab11.iml b/Lab11.iml new file mode 100644 index 0000000..4de040d --- /dev/null +++ b/Lab11.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/TestArray.scala b/src/TestArray.scala new file mode 100644 index 0000000..64acc84 --- /dev/null +++ b/src/TestArray.scala @@ -0,0 +1,9 @@ +object TestArray extends App { + def arrayAvg(arr: Array[Double]): Double = { + if (arr.isEmpty) return 0 + return arr.sum / arr.length + } + + val arr: Array[Double] = Array.range(1, 1001).map(i => i.toDouble) + println(arrayAvg(arr)) +}