# Problems with creating a matrix with functions

I have a function which gives me all the coordinates of a certain bloc in a lattice (with the help of another function for rows and columns):

(*
len = length of line
x0,y0 = position of first site
lc: orientation ("r"=row, "c"=colomn)
*)
line[len_, x0_: 0, y0_: 0, rc_: "r"] := Block[{linelist, i},

If[rc == "r",
linelist = Table[{rx, y0}, {rx, x0, x0 + len - 1}];
,
linelist = Table[{x0, ry}, {ry, y0, y0 + len - 1}];
];

linelist

]

(*
len(i) = length of bloc in i direction
x0,y0 = position of first site (down-left corner)
*)
bloc[lenx_, leny_, x0_: 0, y0_: 0] := Block[{bloclist},

bloclist = {};

For[i = y0, i < y0 + leny, i++,
Block[{},
bloclist = Level[Append[bloclist, line[lenx, x0, i, "r"]], {-2}];
]
];

bloclist

]


The problem is, when I try do make this table

Table[bloc[a, i, 0, 7], {i, 1, 1}, {a, 1, 2}]


it gives me

{{{{0, 7}}, {{0, 7}, {1, 7}, {0, 8}, {1, 8}, {0, 9}, {1, 9}, {0,
10}, {1, 10}, {0, 11}, {1, 11}, {0, 12}, {1, 12}, {0, 13}, {1,
13}, {0, 14}, {1, 14}}}}


{{{{0,7}},{{0,7},{1,7}}}}


Where do all those other terms come from? How can I fix this?

(which is a simplified version of what I must do):

• Maybe because of the way you did the Table. If you evaluate this: Table[bloc[a, 1, 0, 7], {a, 1, 2}], it gives you (mostly) what you want. There is one less level than what you originally expected. {{{0, 7}}, {{0, 7}, {1, 7}}} – Mark R Jun 12 '19 at 21:25
• That said, the experiment: Table[myfun[a, i, 0, 7], {i, 1, 1}, {a, 1, 2}] yields the same as Table[myfun[a,1,0,7],{a,1,2}] so what you tried to do was reasonable. Namely, {myfun[1, 1, 0, 7], myfun[2, 1, 0, 7]} – Mark R Jun 12 '19 at 21:30
• Actually, the outputs from the two are slightly different. Table[myfun[a, i, 0, 7], {i, 1, 1}, {a, 1, 2}] gives {{myfun[1, 1, 0, 7], myfun[2, 1, 0, 7]}} whereas Table[myfun[a, 1, 0, 7], {a, 1, 2}] gives {myfun[1, 1, 0, 7], myfun[2, 1, 0, 7]}. – Mark R Jun 12 '19 at 22:01

line[len_, x0_: 0, y0_: 0, "r"] := Table[{rx, y0}, {rx, x0, x0 + len - 1}]