Or ...
Using ConstantArray
:
mat0 := Most@Flatten[#, 1] & /@
({#, .25 + #} & /@ ConstantArray[#, Ceiling[(Length@#)/2]]&@
Range[0, #, .5] &) ;
[email protected]
(* gives *)
{{0., 0.5, 1., 1.5, 2.}, {0.25, 0.75, 1.25, 1.75, 2.25}, {0., 0.5, 1.,
1.5, 2.}, {0.25, 0.75, 1.25, 1.75, 2.25}, {0., 0.5, 1., 1.5,
2.}}
Using Table
:
mat2:=Most@Flatten[#, 1] & /@ (Transpose /@
Table[{#, .25 + #} & /@ #, {Ceiling[(Length@#1)/2]}] &@ Range[0, #, .5] &)
Using NestList
:
mat3:=Most@Flatten[#, 1] & /@
(NestList[Join, {#1, #2}, Floor[(Length@#1)/2]] & @@ {#, .25 + #} &
@Range[0, #, .5] &)
Using Table
again (less cluttered and more general):
mat4:= Table[{#2, #1}[[1 + Mod[i, 2]]], {i, #3}] &;
mat5 := Table[{#1, #2}[[1 + Mod[i, 2]]], {i, 0, #3 - 1}] &;
mat4[{a, b, c, d}, {e, f, g}, 5]
(* and *)
mat5[{a, b, c, d}, {e, f, g}, 5]
(* both give *)
{{a, b, c, d}, {e, f, g}, {a, b, c, d}, {e, f, g}, {a, b, c, d}}