Re: Let and Get Message #8 Posted by Vincent Weber on 29 June 2006, 12:44 p.m., in response to message #7 by bill platt
Hi,
To go more in depth on L() and G():
These functions let you create and recall intermediate variables. They also provide you with an variable affectation mechanism, which does not normally exist in a 'pure' equation solving environment. Using G(A) instead of just 'A' ensures that the variable will remain hidden from the menu. When you use L() and G() to create statements rather than values, it is commun to prefix them with 0x, so that their return value has no side effect: for example, 0xL(A:SIN(X)/X)+3*G(A)^2+G(A)+4 will affect A while not 'polluting' the expression with the value of A.
If you couple this with the Sum function, you get a possibility to create true definite loops rather that just sums; add the IF statement, and you get conditionals - this starts looking like BASIC, does'nt it ?
The limitations are the following:
1/You can't create you own subroutines/functions. A pity really - something like DEF SIN(X)=<definition of a sine> would allow the 17BII+ not only to have trigs, but to reuse them in programs.
2/You can't have indirect adressing except read-only when you iterate on lists; that makes it impossible to create your own lists or arrays within programs
3/You can't have indefinite loops, the number of times you iterate must be known before entering the loop (you can however simulate indifinite loops by looping a number of times which is for sure higher that the maximum possible, and get the same effect, albeit in a slower manner).
Despite these limitations, these abilities makes the 17BII/19BII/27S/200LX a joy to program, in a concise BASIC fashion, fully integrated with the powerful and elegatant solver ! that's why I am a bit disgusted to hear sometimes these machines reffered to as 'non programmables'.
It is pretty easy to emulate L() and G() in RPL: the arrow '->' allows to create local variables, know only to the block they create, and they can be recalled easily just by typing their name; less concise, though... and I could't find in RPL the equivalent of the S() function which allows to mix several equations into one depending on which value you want to solve for. Anyone ?
Cheers,
Vincent
|