1 calc shell script examples
2 --------------------------
4 These calc shell scripts are provided because they serve as examples of
5 how use the calc language, and/or because the authors thought them to
8 Please note that calc shell scripts must start with the line:
10 #!/usr/local/src/cmd/calc/calc -q -f
12 The above line MUST start in column 1 of the first line. The first line
13 must also end in -f. The -q is optional, but is recommended to disable
14 the processing of calc startup scripts.
16 Also please note that single # shell line comments are not supported in calc.
17 Comments must be /* c-like comment */ or start with a double ## symbol.
19 This is the correct way to form a calc shell script:
21 #!/usr/local/src/cmd/calc/calc -q -f
23 /* a correct comment */
24 ## another correct comment
25 ### two or more together is also a comment
27 * another correct comment
29 print "2+2 =", 2+2; ## yet another comment
31 The first argument after the path to calc executable must be an -S.
32 The next arguments are optional. The -q is often recommended because
33 it will disable the processing of the startup scripts.
35 For more informaton about calc command lines, see "help usage".
37 This next example WRONG:
39 #!/usr/local/src/cmd/calc/calc -q
41 # This is not a calc calc comment because it has only a single #
42 # You must to start comments with ## or /*
43 # is is also wrong because the first line does not end in -f
44 print "This example has invalid comments"
48 If you write something that you think is useful, please send it to:
50 calc-contrib at asthe dot com
52 [[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]]
53 [[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]]
64 Determine if 6 points lie on the surface of a 4-dimensional sphere in R^4.
66 4dsphere x0 y0 z0 w0 x1 y1 z1 w1 ... x5 y5 z5 w5
68 x0 y0 z0 w0 point 0 in R^4
69 x1 y1 z1 w1 point 1 in R^4
71 x5 y5 z5 w5 point 5 in R^4
74 fproduct filename term ...
76 Write the big Endian product of terms to a file. Use - for stdout.
81 Print the value of 2^exp-1.
86 Print the value of pi forever, or as long as you cpu / memory allows.
91 Print the sum of 1 or more arguments.
94 powerterm [base_limit] value
96 Print the value as a sum (or difference) of powers of integers up
97 to and including powers <= base_limit. By default, base_limit is 10000.
102 A trivial example of a calc shell script.
104 ## Copyright (C) 1999 Landon Curt Noll
106 ## Calc is open software; you can redistribute it and/or modify it under
107 ## the terms of the version 2.1 of the GNU Lesser General Public License
108 ## as published by the Free Software Foundation.
110 ## Calc is distributed in the hope that it will be useful, but WITHOUT
111 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
112 ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
113 ## Public License for more details.
115 ## A copy of version 2.1 of the GNU Lesser General Public License is
116 ## distributed with calc under the filename COPYING-LGPL. You should have
117 ## received a copy with calc; if not, write to Free Software Foundation, Inc.
118 ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
120 ## @(#) $Revision: 30.1 $
121 ## @(#) $Id: README.src,v 30.1 2007/03/16 11:12:11 chongo Exp $
122 ## @(#) $Source: /usr/local/src/bin/calc/cscript/RCS/README.src,v $
124 ## Under source code control: 1999/12/17 10:23:40
125 ## File existed as early as: 1999
127 ## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
128 ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/