A Random Number List

depricationが出てらー。

scala> def randList(len: Int,n:Int)={
     | val gen = new Random
     | 1 to len map((x:Int) => gen.nextInt(n))
     | }
warning: there were deprecation warnings; re-run with -deprecation for details
randList: (Int,Int)RandomAccessSeq.Projection[Int]

scala> randList(5,10)
res0: RandomAccessSeq.Projection[Int] = RangeM(4, 2, 0, 7, 3)

ruby

def rand_array(x,y)
  array=[]
  x.times {array<<rand(y)}
  array
end

>> rand_array(5,10)
=> [9, 1, 9, 5, 8]

#こうすべきか
def rand_array(x,y)
  (1..x).map {|i| rand(y) }
end

>> rand_array(5,10)
=> [6, 0, 5, 7, 3]