Release calc version 2.12.1.8

This commit is contained in:
Landon Curt Noll
2007-02-06 17:48:06 -08:00
parent ee30d787ea
commit 810e541281
22 changed files with 563 additions and 633 deletions

View File

@@ -1,4 +1,4 @@
#!/usr/local/src/cmd/calc/calc -q -s -f
#!/usr/local/src/cmd/calc/calc -q -f
/*
* 4dsphere - determine if 6 points lie on the surface of a sphere in R^4
*
@@ -26,8 +26,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 1.3 $
* @(#) $Id: 4dsphere.calc,v 1.3 2001/06/06 09:06:29 chongo Exp $
* @(#) $Revision: 1.4 $
* @(#) $Id: 4dsphere.calc,v 1.4 2007/02/07 00:34:04 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/4dsphere.calc,v $
*
* Under source code control: 2001/05/03 19:02:03

View File

@@ -17,8 +17,8 @@
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.28 $
# @(#) $Id: Makefile,v 29.28 2006/09/18 13:13:25 chongo Exp $
# @(#) $Revision: 29.31 $
# @(#) $Id: Makefile,v 29.31 2007/02/07 01:43:56 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $
#
# Under source code control: 1999/11/29 11:10:26
@@ -199,7 +199,7 @@ SCRIPT_SRC= 4dsphere.calc fproduct.calc mersenne.calc \
# These files are found (but not built) in the distribution
#
DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README
DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README.src
# These files are used to make (but not build) a calc .a library
#
@@ -211,12 +211,16 @@ CALCLIBLIST=
# in the upper level ../Makefile
#
CSCRIPT_TARGETS= ${SCRIPT}
TARGETS= ${CSCRIPT_TARGETS}
TARGETS= ${CSCRIPT_TARGETS} README
# The reason for this Makefile
#
all: ${TARGETS} .all
README: README.src
@${RM} -f $@
@${SED} -e "s:#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
# used by the upper level Makefile to determine if we have done all
#
# NOTE: Due to bogus shells found on one common system we must have

View File

@@ -5,6 +5,46 @@ These calc shell scripts are provided because they serve as examples of
how use the calc language, and/or because the authors thought them to
be useful!
Please note that calc shell scripts must start with the line:
#!/usr/local/src/cmd/calc/calc -q -f
The above line MUST start in column 1 of the first line. The first line
must also end in -f. The -q is optional, but is recommended to disable
the processing of calc startup scripts.
Also please note that single # shell line comments are not supported in calc.
Comments must be /* c-like comment */ or start with a double ## symbol.
This is the correct way to form a calc shell script:
#!/usr/local/src/cmd/calc/calc -q -f
/* a correct comment */
## another correct comment
### two or more together is also a comment
/*
* another correct comment
*/
print "2+2 =", 2+2; ## yet another comment
The first argument after the path to calc executable must be an -S.
The next arguments are optional. The -q is often recommended because
it will disable the processing of the startup scripts.
For more informaton about calc command lines, see "help usage".
This next example WRONG:
#!/usr/local/src/cmd/calc/calc -q
# This is not a calc calc comment because it has only a single #
# You must to start comments with ## or /*
# is is also wrong because the first line does not end in -f
print "This example has invalid comments"
#####
If you write something that you think is useful, please send it to:
calc-contrib at asthe dot com
@@ -77,9 +117,9 @@ simple
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.10 $
## @(#) $Id: README,v 29.10 2001/06/10 19:34:40 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/README,v $
## @(#) $Revision: 29.11 $
## @(#) $Id: README.src,v 29.11 2007/02/07 00:33:10 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/README.src,v $
##
## Under source code control: 1999/12/17 10:23:40
## File existed as early as: 1999

View File

@@ -1,4 +1,4 @@
#!/usr/local/src/cmd/calc/calc -q -s -f
#!/usr/local/src/cmd/calc/calc -q -f
/*
* fproduct - write the big Endian product of terms to a file
*
@@ -24,8 +24,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: fproduct.calc,v 29.2 2001/06/06 09:06:29 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: fproduct.calc,v 29.3 2007/02/07 00:34:04 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/fproduct.calc,v $
*
* Under source code control: 2001/04/07 20:13:11

View File

@@ -1,35 +1,36 @@
#!/usr/local/src/cmd/calc/calc -q -s -f
#
# mersenne - print the value of a mersenne number
#
# 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.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.3 $
# @(#) $Id: mersenne.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/mersenne.calc,v $
#
# Under source code control: 1999/11/30 00:09:01;
# File existed as early as: 1999
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# usage:
# mersenne exp
#!/usr/local/src/cmd/calc/calc -q -f
/*
* mersenne - print the value of a mersenne number
*
* Copyright (C) 1999-2007 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.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: mersenne.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/mersenne.calc,v $
*
* Under source code control: 1999/11/30 00:09:01;
* File existed as early as: 1999
*
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*
* usage:
* mersenne exp
*/
/*

View File

@@ -1,35 +1,36 @@
#!/usr/local/src/cmd/calc/calc -q -f
#
# piforever - print digits of pi forever (or as long as your mem/cpu allow)
#
# 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.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.3 $
# @(#) $Id: piforever.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/piforever.calc,v $
#
# Under source code control: 1999/11/30 00:11:36
# File existed as early as: 1999
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# usage:
# piforever
/*
* piforever - print digits of pi forever (or as long as your mem/cpu allow)
*
* Copyright (C) 1999-2007 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.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: piforever.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/piforever.calc,v $
*
* Under source code control: 1999/11/30 00:11:36
* File existed as early as: 1999
*
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*
* usage:
* piforever
*/
read -once pi.cal

View File

@@ -1,35 +1,36 @@
#!/usr/local/src/cmd/calc/calc -q -s -f
#
# plus - add two or more arguments together
#
# 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.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.3 $
# @(#) $Id: plus.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/plus.calc,v $
#
# Under source code control: 1999/11/29 10:22:37
# File existed as early as: 1999
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
# usage:
# plus val ...
#!/usr/local/src/cmd/calc/calc -q -f
/*
* plus - add two or more arguments together
*
* Copyright (C) 1999-2007 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.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: plus.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/plus.calc,v $
*
* Under source code control: 1999/11/29 10:22:37
* File existed as early as: 1999
*
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*
* usage:
* plus val ...
*/
/*

View File

@@ -1,4 +1,4 @@
#!/usr/local/src/cmd/calc/calc -q -s -f
#!/usr/local/src/cmd/calc/calc -q -f
/*
* powerterm - print the argument as a sum of powers of integers
*
@@ -24,8 +24,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.6 $
* @(#) $Id: powerterm.calc,v 29.6 2001/06/06 09:06:29 chongo Exp $
* @(#) $Revision: 29.7 $
* @(#) $Id: powerterm.calc,v 29.7 2007/02/07 00:34:04 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/powerterm.calc,v $
*
* Under source code control: 2001/04/24 23:49:11

View File

@@ -1,32 +1,33 @@
#!/usr/local/src/cmd/calc/calc -q -f
#
# simple - an example of a simple calc shell script
#
# 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.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.3 $
# @(#) $Id: simple.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/simple.calc,v $
#
# Under source code control: 1999/11/29 10:22:37
# File existed as early as: 1999
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
/*
* simple - an example of a simple calc shell script
*
* Copyright (C) 1999-2007 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.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: simple.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/simple.calc,v $
*
* Under source code control: 1999/11/29 10:22:37
* File existed as early as: 1999
*
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
/*

View File

@@ -1,64 +1,67 @@
#!/usr/local/src/cmd/calc/calc -q -f
#
# sqaure - print the squares of input values
#
# Copyright (C) 2000 Ernest Bowen
#
# 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.
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#
# @(#) $Revision: 29.3 $
# @(#) $Id: square.calc,v 29.3 2000/12/17 14:31:58 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/square.calc,v $
#
# Under source code control: 2000/12/15 06:52:01
# File existed as early as: 2000
#
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
/*
* sqaure - print the squares of input values
*
* Copyright (C) 2000-2007 Ernest Bowen
*
* 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.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: square.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/square.calc,v $
*
* Under source code control: 2000/12/15 06:52:01
* File existed as early as: 2000
*
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
*/
/*
* Usage:
*
* From the shell:
*
* ./square
* cat file | ./square
* echo "123" | ./square
*
* Within calc:
*
* > read square
*
* With input from a terminal, there is no prompt but each non-empty
* line of input is evaluated as a calc expression and if it can be
* calculated, the square of the value of that expression is displayed.
* Execution stops when an empty line is input.
*
* From the shell:
*
* ./square
*
* The following shows lines of input followed by output:
*
* 1234
* 1522756
* ln(2)
* ~.48045301391820142467
* config("mode","frac"), bernoulli(10)
* 25/4356
* config("mode", "hex"), 0xff
* 0xfe01
*/
# Usage:
#
# From the shell:
#
# ./square
# cat file | ./square
# echo "123" | ./square
#
# Within calc:
#
# > read square
#
# With input from a terminal, there is no prompt but each non-empty
# line of input is evaluated as a calc expression and if it can be
# calculated, the square of the value of that expression is displayed.
# Execution stops when an empty line is input.
#
# From the shell:
#
# ./square
#
# The following shows lines of input followed by output:
#
# 1234
# 1522756
# ln(2)
# ~.48045301391820142467
# config("mode","frac"), bernoulli(10)
# 25/4356
# config("mode", "hex"), 0xff
# 0xfe01
#
global s;
while ((s = prompt("")))