1 #!/usr/local/src/cmd/calc/calc -q -f
3 * sqaure - print the squares of input values
5 * Copyright (C) 2000-2007 Ernest Bowen
7 * Calc is open software; you can redistribute it and/or modify it under
8 * the terms of the version 2.1 of the GNU Lesser General Public License
9 * as published by the Free Software Foundation.
11 * Calc is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 * Public License for more details.
16 * A copy of version 2.1 of the GNU Lesser General Public License is
17 * distributed with calc under the filename COPYING-LGPL. You should have
18 * received a copy with calc; if not, write to Free Software Foundation, Inc.
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * @(#) $Revision: 30.1 $
22 * @(#) $Id: square.calc,v 30.1 2007/03/16 11:12:11 chongo Exp $
23 * @(#) $Source: /usr/local/src/bin/calc/cscript/RCS/square.calc,v $
25 * Under source code control: 2000/12/15 06:52:01
26 * File existed as early as: 2000
28 * Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
38 * echo "123" | ./square
44 * With input from a terminal, there is no prompt but each non-empty
45 * line of input is evaluated as a calc expression and if it can be
46 * calculated, the square of the value of that expression is displayed.
47 * Execution stops when an empty line is input.
53 * The following shows lines of input followed by output:
58 * ~.48045301391820142467
59 * config("mode","frac"), bernoulli(10)
61 * config("mode", "hex"), 0xff
67 while ((s = prompt("")))