Skip to main content
deleted 731 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
n = 10;
a = Range[1./n, 1, 1/n]

{{0.1}, {0.2}, {0.3}, {0.4}, {0.5}, {0.6}, {0.7}, {0.8}, {0.9}, {1.}}

SeedRandom[777]
lengths = RandomInteger[{1, 3}, n];
b = MapIndexed[Function[{v, i}, Array[x[i[[1]], #] &, v]], lengths]

{{x[1, 1]},
{x[2, 1], x[2, 2], x[2, 3]},
{x[3, 1], x[3, 2], x[3, 3]},
{x[4, 1]},
{x[5, 1]},
{x[6, 1], x[6, 2], x[6, 3]},
{x[7, 1]},
{x[8, 1], x[8, 2]},
{x[9, 1]},
{x[10, 1]}}

Join @@ (Thread /@ Thread[{Flatten @ a, b}])      

{{0.1, x[1, 1]},
{0.2, x[2, 1]}, {0.2, x[2, 2]}, {0.2, x[2, 3]},
{0.3, x[3, 1]}, {0.3, x[3, 2]}, {0.3, x[3, 3]},
{0.4, x[4, 1]},
{0.5, x[5, 1]},
{0.6, x[6, 1]}, {0.6, x[6, 2]}, {0.6, x[6, 3]},
{0.7, x[7, 1]},
{0.8, x[8, 1]}, {0.8, x[8, 2]},
{0.9, x[9, 1]},
{1., x[10, 1]}}

enter image description here

n = 10;
a = Range[1./n, 1, 1/n]

{{0.1}, {0.2}, {0.3}, {0.4}, {0.5}, {0.6}, {0.7}, {0.8}, {0.9}, {1.}}

SeedRandom[777]
lengths = RandomInteger[{1, 3}, n];
b = MapIndexed[Function[{v, i}, Array[x[i[[1]], #] &, v]], lengths]

{{x[1, 1]},
{x[2, 1], x[2, 2], x[2, 3]},
{x[3, 1], x[3, 2], x[3, 3]},
{x[4, 1]},
{x[5, 1]},
{x[6, 1], x[6, 2], x[6, 3]},
{x[7, 1]},
{x[8, 1], x[8, 2]},
{x[9, 1]},
{x[10, 1]}}

Join @@ (Thread /@ Thread[{Flatten @ a, b}])      

{{0.1, x[1, 1]},
{0.2, x[2, 1]}, {0.2, x[2, 2]}, {0.2, x[2, 3]},
{0.3, x[3, 1]}, {0.3, x[3, 2]}, {0.3, x[3, 3]},
{0.4, x[4, 1]},
{0.5, x[5, 1]},
{0.6, x[6, 1]}, {0.6, x[6, 2]}, {0.6, x[6, 3]},
{0.7, x[7, 1]},
{0.8, x[8, 1]}, {0.8, x[8, 2]},
{0.9, x[9, 1]},
{1., x[10, 1]}}

Join @@ (Thread /@ Thread[{Flatten @ a, b}])      

enter image description here

added 84 characters in body
Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929
n = 10;
a = Range[1./n, 1, 1/n];n]

{{0.1}, {0.2}, {0.3}, {0.4}, {0.5}, {0.6}, {0.7}, {0.8}, {0.9}, {1.}}

SeedRandom[777]
lengths = RandomInteger[{1, 3}, n];
b = MapIndexed[Function[{v, i}, Array[x[i[[1]], #] &, v]], lengths]

{{x[1, 1]},
{x[2, 1], x[2, 2], x[2, 3]},
{x[3, 1], x[3, 2], x[3, 3]},
{x[4, 1]},
{x[5, 1]},
{x[6, 1], x[6, 2], x[6, 3]},
{x[7, 1]},
{x[8, 1], x[8, 2]},
{x[9, 1]},
{x[10, 1]}}

Join @@ (Thread /@ Thread[{Flatten @ a, b}])      

{{0.1, x[1, 1]},
{0.2, x[2, 1]}, {0.2, x[2, 2]}, {0.2, x[2, 3]},
{0.3, x[3, 1]}, {0.3, x[3, 2]}, {0.3, x[3, 3]},
{0.4, x[4, 1]},
{0.5, x[5, 1]},
{0.6, x[6, 1]}, {0.6, x[6, 2]}, {0.6, x[6, 3]},
{0.7, x[7, 1]},
{0.8, x[8, 1]}, {0.8, x[8, 2]},
{0.9, x[9, 1]},
{1., x[10, 1]}}

n = 10;
a = Range[1./n, 1, 1/n];
SeedRandom[777]
lengths = RandomInteger[{1, 3}, n];
b = MapIndexed[Function[{v, i}, Array[x[i[[1]], #] &, v]], lengths]

{{x[1, 1]},
{x[2, 1], x[2, 2], x[2, 3]},
{x[3, 1], x[3, 2], x[3, 3]},
{x[4, 1]},
{x[5, 1]},
{x[6, 1], x[6, 2], x[6, 3]},
{x[7, 1]},
{x[8, 1], x[8, 2]},
{x[9, 1]},
{x[10, 1]}}

Join @@ (Thread /@ Thread[{a, b}])      

{{0.1, x[1, 1]},
{0.2, x[2, 1]}, {0.2, x[2, 2]}, {0.2, x[2, 3]},
{0.3, x[3, 1]}, {0.3, x[3, 2]}, {0.3, x[3, 3]},
{0.4, x[4, 1]},
{0.5, x[5, 1]},
{0.6, x[6, 1]}, {0.6, x[6, 2]}, {0.6, x[6, 3]},
{0.7, x[7, 1]},
{0.8, x[8, 1]}, {0.8, x[8, 2]},
{0.9, x[9, 1]},
{1., x[10, 1]}}

n = 10;
a = Range[1./n, 1, 1/n]

{{0.1}, {0.2}, {0.3}, {0.4}, {0.5}, {0.6}, {0.7}, {0.8}, {0.9}, {1.}}

SeedRandom[777]
lengths = RandomInteger[{1, 3}, n];
b = MapIndexed[Function[{v, i}, Array[x[i[[1]], #] &, v]], lengths]

{{x[1, 1]},
{x[2, 1], x[2, 2], x[2, 3]},
{x[3, 1], x[3, 2], x[3, 3]},
{x[4, 1]},
{x[5, 1]},
{x[6, 1], x[6, 2], x[6, 3]},
{x[7, 1]},
{x[8, 1], x[8, 2]},
{x[9, 1]},
{x[10, 1]}}

Join @@ (Thread /@ Thread[{Flatten @ a, b}])      

{{0.1, x[1, 1]},
{0.2, x[2, 1]}, {0.2, x[2, 2]}, {0.2, x[2, 3]},
{0.3, x[3, 1]}, {0.3, x[3, 2]}, {0.3, x[3, 3]},
{0.4, x[4, 1]},
{0.5, x[5, 1]},
{0.6, x[6, 1]}, {0.6, x[6, 2]}, {0.6, x[6, 3]},
{0.7, x[7, 1]},
{0.8, x[8, 1]}, {0.8, x[8, 2]},
{0.9, x[9, 1]},
{1., x[10, 1]}}

Source Link
kglr
  • 400.5k
  • 18
  • 488
  • 929

n = 10;
a = Range[1./n, 1, 1/n];
SeedRandom[777]
lengths = RandomInteger[{1, 3}, n];
b = MapIndexed[Function[{v, i}, Array[x[i[[1]], #] &, v]], lengths]

{{x[1, 1]},
{x[2, 1], x[2, 2], x[2, 3]},
{x[3, 1], x[3, 2], x[3, 3]},
{x[4, 1]},
{x[5, 1]},
{x[6, 1], x[6, 2], x[6, 3]},
{x[7, 1]},
{x[8, 1], x[8, 2]},
{x[9, 1]},
{x[10, 1]}}

Join @@ (Thread /@ Thread[{a, b}])      

{{0.1, x[1, 1]},
{0.2, x[2, 1]}, {0.2, x[2, 2]}, {0.2, x[2, 3]},
{0.3, x[3, 1]}, {0.3, x[3, 2]}, {0.3, x[3, 3]},
{0.4, x[4, 1]},
{0.5, x[5, 1]},
{0.6, x[6, 1]}, {0.6, x[6, 2]}, {0.6, x[6, 3]},
{0.7, x[7, 1]},
{0.8, x[8, 1]}, {0.8, x[8, 2]},
{0.9, x[9, 1]},
{1., x[10, 1]}}