persistence
persistence,
an R code which
demonstrates how to initialize, get, or set data stored
within a function, using static/persistent/saved/local memory.
This type of data storage is sometimes referred to as "static memory"
or "persistent memory" or "saved memory".
Several examples are offered here, each embodied in a function.

constants() stores the value of three physical constants,
and returns them. It is not very ambitious.

abc() stores the value of three real numbers, which are
initialized to 1, 2, and 3. The user can request the current
values, or request that they be printed, or can set them to
new values.

stats() accepts, one at a time, a sequence of real numbers.
It internally updates the sum, min, mean, max, variance
and standard deviation of the entire sequence, and can report
the current values of these quantities at any time.

byname() internally stores three variables. The user can access
any one of these variables, by naming the kind of access,
naming the variable to be accessed, and the new value if any, to
be assigned to it.
Licensing:
The computer code and data files made available on this web page
are distributed under
the MIT license
Languages:
persistence is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version and
an Octave version and
a Python version and
an R version.
Related Data and Programs:
persistence_test
Source Code:

abc.R,
stores, saves, and returns variables "a", "b", "c",
using the form "[aout,bout,cout]=abc(ain,bin,cin)";

byname.R,
sets, gets, prints or resets any of three variables
"alpha", "beta", "gamma", which are referenced by name,
using actions "print", "get", "set", or "reset",
using the form "value_out=byname(action,name,value_in)";

constants.R,
saves and returns constants "g", "c", "n",
using the form "[g,c,h]=constants()";

stats.R,
initializes, updates, and outputs running values of
statistical quantities of a sequence of data supplied
one value at a time, using the form
[n,x_sum,x_min,x_mean,x_max,x_var,x_std]=stats(x).
Last modified on 07 May 2021.