Question: unable to evaluate sequence

I have a simple proc that generates some arrays based in some input values.

I have a function that uses the proc to do math on the array. I have anoother function that uses that function to do more things. The last function does not evaluate because it says that it is unable to evaluate the sequence in the proc.


It seems that because I am summing over the first function and the sum variable is "unknown" the proc cannot create the arrays. Maple is trying to "simply" bottom up rather than top down and craps out.


It really has nothing to do with the sequence though but that the input that ultimately gets to the proc involves a negative index. Even though I've attempted to prevent that every possible way such as max(0,j)... even though j is negative higher up in the evaluation maple insists in not clamping it first.



f cannot deal with negative indicides(even though I also have an if j < 0 then return 0; fi; in the proc)


Maple is trying to do some magic annd failing. I've ran in to this problem before and I solved it, I thought, bu using ` ` around the function name... it does not work here.


It seems that maple tries to evaluate everything in the proc regardless of the actual inputs used or the if statements before the evaluation(unlike traditional programming which can be sequentially reasoned).

How to stop it from doing this nonsense and just give me what I want?

Error, (in f) out of bound assignment to a list


f := proc(i) local A; A := [3,4,5]; if i < 0 then return 0; fi; return A[i]; end;


f(-1) works


but when used in other things with a variable it fails.




Please Wait...