Question: piecewise and for-loop

Hi

How can I use loop-varible in a definition of piecewise function? For example, when I do:

for k to 5 do

f[k] := x -> piecewise(x > 0, k, 0);

end do;

f[3](1);

f[2](1);

 

I get:

f[3](1) = 6

f[2](1) = 6

Please Wait...