1+ class X [T ](val x : T ) extends AnyVal
2+ object Test {
3+ def main (args : Array [String ]) = {
4+ def pl (xs : Array [_]) = println(xs.toList)
5+ pl(Array .ofDim[X ](4 ))
6+ pl(Array .ofDim[X ](4 ,3 ))
7+ Array .ofDim[X ](4 ,3 ,2 )
8+ Array .ofDim[X ](4 ,3 ,2 ,5 )
9+ Array .ofDim[X ](4 ,3 ,2 ,5 ,6 )
10+ pl(Array .concat(Array [X ](new X (1 ), new X (2 )), Array [X ](new X (3 ), new X (4 ))))
11+ import scala .collection .mutable .{ WrappedArray , ArrayBuilder }
12+ val ar : WrappedArray [X ] = Array [X ](new X (1 ), new X (2 ))
13+ ar.toArray
14+ val ar0 : WrappedArray [X ] = Array [X ](new X (1 ), new X (2 ))
15+ val ar1 : ArrayBuilder [X ] = ArrayBuilder .make[X ]()
16+ val ar2 = ar1.++= (ar0)
17+ pl(Array .fill(5 )(new X (1 )))
18+ pl(Array .fill(5 ,6 )(new X (1 )))
19+ Array .fill(5 ,6 ,7 )(new X (1 ))
20+ Array .fill(5 ,6 ,7 ,8 )(new X (1 ))
21+ Array .fill(5 ,6 ,7 ,8 ,9 )(new X (1 ))
22+
23+ pl(Array .tabulate(5 )(x => new X (x)))
24+ pl(Array .tabulate(4 ,5 )((x,y) => new X (x + y)))
25+ Array .tabulate(4 ,5 ,6 )((x,y,z) => new X (x + y + z))
26+ Array .tabulate(4 ,5 ,6 ,7 )((x,y,z,q) => new X (x + y + z + q))
27+ Array .tabulate(4 ,5 ,6 ,7 ,8 )((x,y,z,q,w) => new X (x + y + z + q + w))
28+
29+ pl(Array .iterate(new X (5 ), 3 )(xx => new X (2 * xx.x)))
30+ println(Array .unapplySeq(Array [X ](new X (1 ), new X (2 ), new X (3 ))))
31+ }
32+ }
0 commit comments