equal
deleted
inserted
replaced
257 } |
257 } |
258 dups(lst) |
258 dups(lst) |
259 result.toList |
259 result.toList |
260 } |
260 } |
261 |
261 |
|
262 def replicate[A](n: Int, a: A): List[A] = |
|
263 if (n < 0) throw new IllegalArgumentException |
|
264 else if (n == 0) Nil |
|
265 else { |
|
266 val res = new mutable.ListBuffer[A] |
|
267 (1 to n).foreach(_ => res += a) |
|
268 res.toList |
|
269 } |
|
270 |
262 |
271 |
263 /* proper values */ |
272 /* proper values */ |
264 |
273 |
265 def proper[A](x: A): Option[A] = |
274 def proper[A](x: A): Option[A] = |
266 if (x == null) None else Some(x) |
275 if (x == null) None else Some(x) |