Okay, so, I'm trying to write a program within the module. It goes like this: create empty list, join it with a sample from a certain set called MyList, and then repeat it certain number of times. Sounds simple.
Ex[m_] := Module[
{sample={}, i = 0},
While[i < m,
sample= Join[sample, RandomSample[MyList, 7]];
i++]
sample
]
So, Ex[1], should give me just seven numbers, Ex[2] fourteen, etc. But no. It would be too simple. Ex[1] gives me {10 Null, 12 Null, 31 Null, 2 Null, 38 Null, 17 Null, 7 Null}, and so on. Why? What are those nulls everywhere? Have I definied sample wrong? {} is an empty list, quite obviously. Typing manually
Join[{}, {1, 2, 3, 4, 5, 6, 7}]
Gives me no errors.
ex
,myList
. $\endgroup$;
after yourWhile
loop. Note that your while loop basically does whatTable
does (butTable
is more efficient and, more importantly imo, more readable). $\endgroup$