Temporary Variables/Let?


Posted by Eric Snow on May 29, 2001 10:00 AM

Is there anyway to assign a value to a temporary variable in a function, so an entire expression doesn't have to be used over and over? For instance, in scheme you can:
(define ...
(let ((var1 (some expression)))
...other stuff...))

or in C,

int var1=(some expression);
...other stuff...

I imagine this could be done in VBA, but is there any way to get it into just one of the cell formulae?

Thanks

-Eric Snow (who finds working with data structures in his own programs easier, at least until he can figure these things out.)

Posted by Aladin Akyurek on May 29, 2001 10:09 AM

Eric

Love to see a bit Scheme/Lisp. Spreadsheet functions as far as I know do not have the LET-notion. There is maybe a workround or a spreadsheet way in specific cases.

What do you have in mind?

Aladin



Posted by Eric Snow on May 29, 2001 10:20 AM

In one place a have a function that is x/y*sqrt((w/x)^2+(z/y)^2) where x and y are fairly large index lookups. Another spot I wanted to hide the contents of a cell if some large expression were zero, like
=IF(0=(the big expression),"",(the big expression))

Either can be done as is, it's just ugly and inefficient (even though it takes a negligible amount of time to calculate.)