Simple load balancer model in Scala
Below are some of the changes I would make to your code. In my opinion one of the nice aspects of Scala is that it gives you all sorts of ways to reduce the amount of work your mind has to do in order to decipher code. As an example, one of the first things I did was declare a type ArrD that is equivalent to Array[Double]. I then just substitued where necessary and the code (to my mind) became more readable. The choice of ArrD was arbitrary on my part, you could if you wanted use ArrayDouble instead. Along these lines I shortened all of you variable and value names.

As the program is set up right now you don't need to pass in a procs array, but I left it in anyway. As you mentioned this is a homework assignment so I'll leave a bit of mystery as to why this is. And really you don't need the take and the drop.

Next note that jobs.sorted is equivalent to jobs.sortWith(_ &gt; _).

And finally (for now) checkout how I initialized jobs and procs. If you still would like to use your randomElements function you should look into the method called tabulate.

Cheers.

object O {

  type ArrD = Array[Double]

  def findMaxSolver(procs: ArrD, jobs: ArrD): Double = {
    val sJobs  = jobs.sorted
    var sProcs = sJobs.take(procs.size)

    for(job &lt;- sJobs.drop(procs.size)){
      sProcs     = sProcs.sorted
      sProcs(0) += job
    }
    sProcs.max
  }

  def solve(procs: ArrD, jobs: ArrD, f: (ArrD, ArrD) =&gt; Double) = f(procs, jobs)

  def run = {
    val jobNum  = 1024
    val procNum = 8
    val jobs    = Array.fill(jobNum)(scala.util.Random.nextDouble())
    val procs   = Array.fill(procNum)(0.0)
    println(s"RESULTS:\nFind max solver ${solve(procs, jobs, findMaxSolver)}")
  }
}