Question: How to deal with using previously computed values in certain expressions

I have hacked together some things so I can use previously computed values without too much hassle

_Last := 0:
# Stores N in a global to be used
Last := proc(N)
    global _Last;
    _Last := N;


_Last := 1:

seq(Last(_Last*4 + k),k=1..10);


This is quite hacky but does work. It is not very robust. Is there any better way? [The above is just a trivial example, I know it can be solved as a problem easily, that is not the point. The method can also be used in much more non-trivial scenarios to simplify coding them].



Please Wait...