Question: Sums and cycles with functions in Maple

At one step of my code I need to define an array of functions which I will later use.

Simplified version of it to highlight the problem:

restart:with(linalg):
procG:=proc(a,b) if a>b then a-b else 0 end if end proc:
F:=vector(2):
for i from 1 to 2 do F[i]:=x->i*procG(x,0) end;

In the actual code array is much bigger and the expression for each function is much more complicated so using the cycle is a real 'must'.

Instead of F[1]=1*procG(x,0) and F[2]=2*procG(x,0) I get F[1]=i*procG(x,0) and F[2]=i*procG(x,0).

If I define F[i] not as a function of x but as an expression to later use the "unapply(F,x)" command, I get an error that expression F cannot be evaluated (Error, (in procG) cannot determine if this expression is true or false: 0 < x).

 

Is there any workaround for this or, perhaps, there's a with(..) command that I'm missing ? 

 

Please Wait...