B - Spline Basis Functions

bs[i_, 1, knots_][x_] := Piecewise[{{1, knots[[i]]<=x<knots[[i+1]]}}];
w[i_, order_, knots_][x_] := Piecewise[{
{(x-knots[[i]])/(knots[[i+order-1]]-knots[[i]]), knots[[i]]<=x<knots[[i+order-1]]},
        {1, x>=knots[[i+order-1]]},
        {0, x<knots[[i]]}
        }];
bs[i_, order_, knots_][y_] :=w[i, order, knots][y]*bs[i, order-1, knots][y] + (1-w[i+1, order, knots][y])*bs[i+1, order-1, knots][y];
BSpline[i_,order_,knots_][x_]:=bs[i,order,Sort@knots][x]
BSpline::usage="BSpline[i,order,knots] gives the i-th BSpline of some order with respect to the knot sequence knots.";
Manipulate[If[Length[pts]≠d+num,
pts=Table[{k,0},{k,0,d+num-1}]];
Do[f[i][x_]=BSpline[i,d,First/@pts][x],{i,num}];
Plot[Evaluate@Table[f[i][x],{i,num}],{x,0,d+num-1},Epilog->Point/@pts,Filling->Axis,PlotRange->{0,1},PlotPoints->91*(d+num),ImageSize->{600,400},Exclusions->None],
{{pts,{{0,0},{1,0},{2,0},{3,0},{4,0}}},{0,0},{d+num-1,0},Locator},
{{d,3,"order"},1,5,1,Appearance->"Labeled"},
{{num,2,"number"},1,10,1,Appearance->"Labeled"},
TrackedSymbols->Manipulate,SaveDefinitions->True]