Files
calc/help/expression
Landon Curt Noll a31078bbec Remove all RCS @(#) lines and RCS strings
Some folks might think: “you still use RCS”?!?  And we will say,
hey, at least we switched from SCCS to RCS back in … I think it was
around 1994 ... at least we are keeping up! :-) :-) :-)

Logs say that SCCS version 18 became RCS version 19 on 1994 March 18.

RCS served us well.  But now it is time to move on.   And so we are
switching to git.

Calc releases produce a lot of file changes.  In the 125 releases
of calc since 1996, when I started managing calc releases, there
have been 15473 file mods!
2017-05-23 01:33:23 -07:00

58 lines
2.5 KiB
Plaintext

Expression sequences
This is a sequence of statements, of which expression statements
are the commonest case. Statements are separated with semicolons,
and the newline character generally ends the sequence. If any
statement is an expression by itself, or is associated with an
'if' statement which is true, then two special things can happen.
If the sequence is executed at the top level of the calculator,
then the value of '.' is set to the value of the last expression.
Also, if an expression is a non-assignment, then the value of the
expression is automatically printed if its value is not NULL.
Some operations such as pre-increment and plus-equals are also
treated as assignments.
Examples of this are the following:
expression sets '.' to prints
---------- ----------- ------
3+4 7 7
2*4; 8+1; fact(3) 6 8, 9, and 6
x=3^2 9 -
if (3 < 2) 5; else 6 6 6
x++ old x -
print fact(4) - 24
null() null() -
Variables can be defined at the beginning of an expression sequence.
This is most useful for local variables, as in the following example,
which sums the square roots of the first few numbers:
local s, i; s = 0; for (i = 0; i < 10; i++) s += sqrt(i); s
If a return statement is executed in an expression sequence, then
the result of the expression sequence is the returned value. In
this case, '.' is set to the value, but nothing is printed.
## Copyright (C) 1999 Landon Curt Noll
##
## Calc is open software; you can redistribute it and/or modify it under
## the terms of the version 2.1 of the GNU Lesser General Public License
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
## Under source code control: 1991/07/21 04:37:18
## File existed as early as: 1991
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/