part 1 task 0

This commit is contained in:
Louis Heredero 2023-12-04 15:13:48 +01:00
parent 543eb21595
commit 309088e5d2
2 changed files with 21 additions and 0 deletions

12
Lab11.iml Normal file
View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="scala-sdk-2.13.12" level="project" />
</component>
</module>

9
src/TestArray.scala Normal file
View File

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