Containers of containers with fixed dimensions

15 views
Skip to first unread message

Aish Fenton

unread,
Jun 25, 2016, 5:20:26 PM6/25/16
to scalacheck
Hi,
Maybe a simple question, but can't find a way to do achieve this.

I want to produce a 2 dimensional square array. That is Array[Array[Double]], with each inner array having the same dimension. And both inner and outer having the same dimensions.

I did what I thought was the obvious approach:

val inner = Gen.containerOfN[Array, Double](10, Gen.choose(0.0, 1.0) )
val outer = Gen.containerOfN[Array, Array[Double]](10, inner)

But this seems to have two problems. 1) The inner arrays seems to be the same for all entries of outer (I thought inner would be re-sampled for each entry of containerN?). 2) Outer's size gets smaller and smaller rather than being fixed N. 

I guess 2 is related to issue #89 (but I'm little confused by what #89 describes so this maybe wrong).

What is the right way to do this? And if #89 is indeed the problem what is the best work around?

Aish



Reply all
Reply to author
Forward
0 new messages