Question: having a proceedure define a function

I want to have a procedure define a function... If I do: >with(stats); >does_not_work:= proc(t) local v,d0,d1,x,y; > v = rhs(fit[leastsquare[[x,y], y=d0+d1*x]](t)); >end proc; then > does_not_work([[0,1,2],[3,4,5]]); results in "v = 3 + x" as expected, but if I try to have the procedure define a function d as in >does_not_work:= proc(t) local v,d0,d1,x,y; global d; > v = rhs(fit[leastsquare[[x,y], y=d0+d1*x]](t)); > d:= (x) -> v; >end proc; then > does_not_work([[0,1,2],[3,4,5]]); > d(1); does not result in 4, which should be the result of applying the function d to 1 assuming the procedure managed to define the function d to be the result of the least squares fit. So how does one manage to have a procedure define a function?
Please Wait...