Since their introduction way back in Release 3, the intrinsic functions
put()
and get()
have rendered possible the implementation
of many special tasks, that would otherwise not have been possible to
implement. Introduced first as a simple means to avoid the recomputation
of repeated terms in a single expression, with time their use has been
extended to also allow storing and transporting of information from
one expression to the next. Typical applications of the latter type
are random number generation (see e.g. EMME2/NEWS 9, page 8) or the
implementation of multiple linear regressions using the calculator
modules (see e.g. macros
NETREG.MAC
and
MATREG.MAC
on the SHARE diskette).
The basic operation of the put() and get() intrinsics is quite simple: each call to put(X) will store the value X in the next word of a special stack, starting with stack index 1, each time an expression is evaluated, whereas a call to get(I) will return the I-th stack value. With this sequential way of writing to the stack, a small stack size of 20 is plenty, since the used stack size is limited to the maximum number of put() calls that can occur in a single expression.
In Release 8, the put() and get() are complemented by the new intrinsic function puti(), which allows defining explicitly a stack index for the following put() operations. Along with this new possibility of direct addressing when writing to the stack, the size of the stack is also increased from 20 to 250.
These enhancements open many possibilities for novel applications, such as:
put(get(puti(
ClassIndex))+
Weight)
.The usefulness of the put()/get() stack is even further increased by the fact that its contents can now also be accessed directly from macros.
The link speed histogram shown on the plot below has been computed in
module 2.41
with the expression put(get(puti(@speed))+1)
for all different volume-delay functions (which appear on the plot in
different colors) and then displayed in
module 2.43: