Question: Evaluating Vector in a piecewise defined function

Hello,
I'm trying to write a function which is calculating a B-Spline Function. Given is a knot vector U=[u1,...um]. What i want to calculate know is the basis function of degree 0 which is defined by Ni,0(u)=1 if ui <= u < ui+1 and 0 otherwise. I tried to do this with two procs which are leading to the same problem:
procVec1 := proc (U)
m := nops(U);
N := [seq(0, i = 1 .. m-1)];
for i to m-1 do
    N[i] := u -> piecewise(U[i] <= u and u < U[i+1], 1); 
od;
return N;
end;

procVec2 := proc (U)
m := nops(U);
N := [seq(0, i = 1 .. m-1)];
N := [seq( u -> piecewise(U[i] <= u and u < U[i+1], 1), i = 1 .. m-1)];
return N;
end;

When I tested these functions with U:=[0,1,2,3,4]; I got the following result:
N := procVec2(U);
[u -> piecewise([0, 1, 2, 3, 4]i <= u and u < [0, 1, 2, 3, 4]i+1, 1), u -> piecewise([0, 1, 2, 3, 4]i <= u and u < [0, 1, 2, 3, 4]i+1,1), u -> piecewise([0, 1, 2, 3, 4]i <= u and u < [0, 1, 2, 3, 4]i+1, 1), u -> piecewise([0, 1, 2, 3, 4]<= u and u < [0, 1, 2, 3, 4]i+1, 1)]

But the result should be:
[u -> piecewise(0 <= u and u < 1, 1), u -> piecewise(1 <= u and u < 2, 1), u -> piecewise(2 <= u and u <3, 1), u -> piecewise(3 <= u and u < 4, 1)]

So, what can I do, in order to get the U[i] evaluated?
Thanks for your help. 

Please Wait...