Mistři v programování na #hovnokod

Jiné #4615

Trideni v konstantnim case (Scala variant).

import java.util.{Timer,TimerTask}
object SleepSort extends App {
  val timer = new Timer
  def delay(f: () => Unit, n: Long) = {
    timer.schedule(new TimerTask() {
      def run = f()
    }, n)
  }
  def sleepSort(a: Array[Int]) = {
    for (i <- a) delay(() => println(i), i)
  }
  sleepSort(Array(531,112,43,355,911,299,24))
  delay(() => timer.cancel(), 1000)
}

David Strupl,