N-times aynı öğe ile bir liste nasıl oluşturulur?Aynı öğe n-times ile bir liste nasıl oluşturulur?
Manuel implementnation:
scala> def times(n: Int, s: String) =
| (for(i <- 1 to n) yield s).toList
times: (n: Int, s: String)List[String]
scala> times(3, "foo")
res4: List[String] = List(foo, foo, foo)
da aynı şeyi yerleşik bir yolu var mı?
Daha fazla bilgi için bkz: GenTraversableFactory ve # 14 bu sayfada: http://nicholassterling.wordpress.com/2012/01/28/scala-snippets/ – AmigoNico