I was wondering why it seems not possible to put functions into a list using a for loop like below:
K = Table[{}, {2}];
For[i = 1, i <= 2, i++,
S = SmoothKernelDistribution[RandomReal[1, 10]];
Print[PDF[S, 0.5]];
K[[i]] = Function[x, PDF[S, x]];
]
Although S changes, the list K does contain twice the same function.
(It was simplified for 2, usually I have thousands of functions in the loop and S is much more complex.)
Tableinsead ofFore.g.k = Table[.... 2. don't use single capital letters. 3. you need to useWith[{s =s},..trick becauseFunctionisHoldAll. Read more in linked duplicate.