mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Converted all ASCII tabs to ASCII spaces using a 8 character tab stop, for all files, except for all Makefiles (plus rpm.mk). The `git diff -w` reports no changes.
58 lines
2.7 KiB
Plaintext
58 lines
2.7 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/
|