Non-allocating loop over a set of structs

The way you wrote Sample , s1 , s2 and s3 will all have different types.

Does this happens because of the Function field? Can I do something with it, like specify the type of the function’s output?

However, if you deal with known length tuples you can unroll the loop

The number of elements changes from run to run. Can I do the loop unrolling using some kind of metaprogramming magic?

I still do not understand why the result of the loop is so different from the result of unrolling. I thought that under the hood Julia does exactly the same.