title: How to call a method n times in Scala?
body: <p>I have a case where I want to call a method n times, where n is an Int. Is there a good way to do this in a "functional" way in Scala?</p>
  
  <pre><code>case class Event(name: String, quantity: Int, value: Option[BigDecimal])
  
  // a list of events
  val lst = List(
      Event("supply", 3, Some(new java.math.BigDecimal("39.00"))),
      Event("sale", 1, None),
      Event("supply", 1, Some(new java.math.BigDecimal("41.00")))
      )
  
  // a mutable queue
  val queue = new scala.collection.mutable.Queue[BigDecimal]
  
  lst.map { event =&gt;
      event.name match {
          case "supply" =&gt; // call queue.enqueue(event.value) event.quantity times
          case "sale" =&gt;   // call queue.dequeue() event.quantity times
      }
  }
  </code></pre>
  
  <p>I think a closure is a good solution for this, but I can't get it working. I have also tried with a for-loop, but it's not a beautiful functional solution.</p>