ame" which would do nothing if "filename" was not a readable file. ## 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: wishlist,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/wishlist,v $ ## ## Under source code control: 1991/07/21 04:37:24 ## File existed as early as: 1991 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME places - return number of "decimal" places in a fractional part SYNOPSIS places(x [,b]) TYPES x real b integer >= 2, defaults to 10 return integer DESCRIPTION Returns the least non-negative integer n for which b^n * x is an integer, or -1 if there is no such integer. places(x,b) = 0 if and only if x is an integer. If omitted, b is assumed to be 10. If given, b must be an integer > 1. places(x,b) = n > 0 if and only if the fractional part of abs(x) has a finite base-b "decimal" representation with n digits of which the last digit is nonzero. This occurs if and only if every prime factor of den(x) is a factor of b. EXAMPLE ; print places(3), places(0.0123), places(3.70), places(1e-10), places(3/7) 0 4 1 10 -1 ; print places(0.0123, 2), places(.625, 2), places(.625, 8) -1 3 1 LIMITS b > 1 LINK LIBRARY long qplaces(NUMBER *q, ZVALUE base) SEE ALSO digit, digits ## Copyright (C) 1999-2003 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: places,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/places,v $ ## ## Under source code control: 1995/10/03 10:40:02 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME assoc - create a new association array SYNOPSIS assoc() TYPES return association DESCRIPTION This function returns an empty association array. After A = assoc(), elements can be added to the association by assignments of the forms A[a_1] = v_1 A[a_1, a_2] = v_2 A[a_1, a_2, a_3] = v_3 A[a_1, a_2, a_3, a_4] = v_4 There are no restrictions on the values of the "indices" a_i or the "values" v_i. After the above assignments, so long as no new values have been assigned to A[a_i], etc., the expressions A[a_1], A[a_1, a_2], etc. will return the values v_1, v_2, ... Until A[a_1], A[a_1, a_2], ... are defined as described above, these expressions return the null value. Thus associations act like matrices except that different elements may have different numbers (between 1 and 4 inclusive) of indices, and these indices need not be integers in specified ranges. Assignment of a null value to an element of an association does not delete the element, but a later reference to that element will return the null value as if the element is undefined. The elements of an association are stored in a hash table for quick access. The index values are hashed to select the correct hash chain for a small sequential search for the element. The hash table will be resized as necessary as the number of entries in the association becomes larger. The size function returns the number of elements in an association. This size will include elements with null values. Double bracket indexing can be used for associations to walk through the elements of the association. The order that the elements are returned in as the index increases is essentially random. Any change made to the association can reorder the elements, this making a sequential scan through the elements difficult. The search and rsearch functions can search for an element in an association which has the specified value. They return the index of the found element, or a NULL value if the value was not found. Associations can be copied by an assignment, and can be compared for equality. But no other operations on associations have meaning, and are illegal. EXAMPLE ; A = assoc(); print A assoc (0 elements): ; A["zero"] = 0; A["one"] = 1; A["two"] = 2; A["three"] = 3; ; A["smallest", "prime"] = 2; ; print A assoc (5 elements); ["two"] = 2 ["three"] = 3 ["one"] = 1 ["zero"] = 0 ["smallest","prime"] = 2 LIMITS none LINK LIBRARY none SEE ALSO isassoc, rsearch, search, size ## 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: assoc,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/assoc,v $ ## ## Under source code control: 1994/09/25 20:22:31 ## File existed as early as: 1994 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ Credits The majority of calc was written by David I. Bell. The Calc primary mirror, calc mailing list and calc bug report processing is performed by Landon Curt Noll. Landon Curt Noll maintains the master reference source, performs release control functions as well as other calc maintenance functions. Thanks for suggestions and encouragement from Peter Miller, Neil Justusson, Ernest W. Bowen and Landon Noll. Thanks to Stephen Rothwell for writing the original version of hist.c which is used to do the command line editing. Thanks to Ernest W. Bowen for supplying many improvements in accuracy and generality for some numeric functions. Much of this was in terms of actual code which I gratefully accepted. Ernest also supplied the original text for many of the help files. Portions of this program are derived from an earlier set of public domain arbitrarily precision routines which was posted to the net around 1984. By now, there is almost no recognizable code left from that original source. Most of this source and binary has one of the following copyrights: Copyright (C) year David I. Bell Copyright (C) year David I. Bell and Landon Curt Noll Copyright (C) year David I. Bell and Ernest Bowen Copyright (C) year David I. Bell, Landon Curt Noll and Ernest Bowen Copyright (C) year Landon Curt Noll Copyright (C) year Ernest Bowen and Landon Curt Noll Copyright (C) year Ernest Bowen Copying / Calc GNU Lesser General Public License Calc is open software, and is covered under version 2.1 of the GNU Lesser General Public License. You are welcome to change it and/or distribute copies of it under certain conditions. The calc commands: help copying help copying-lgpl should display the contents of the COPYING and COPYING-LGPL files. Those files contain information about the calc's GNU Lesser General Public License, and in particular the conditions under which you are allowed to change it and/or distribute copies of it. You should have received a copy of the version 2.1 GNU Lesser General Public License. If you do not have these files, write to: Free Software Foundation, Inc. 51 Franklin Street Fifth Floor Boston, MA 02110-1301 USA See also: help copyright help copying help copying-lgpl ## 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: credit,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/credit,v $ ## ## Under source code control: 1991/07/23 05:47:24 ## File existed as early as: 1991 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME delete - delete an element from a list at a specified position SYNOPSIS delete(lst, index) TYPES lst list index nonnegative integer less than the size of the list return type of the deleted element DESCRIPTION Deletes element at the specified index from list lst, and returns the value of this element. EXAMPLE ; lst = list(2,3,4,5) list (4 elements, 4 nonzero): [[0]] = 2 [[1]] = 3 [[2]] = 4 [[3]] = 5 ; delete(lst, 2) 4 ; print lst list (3 elements, 3 nonzero): [[0]] = 2 [[1]] = 3 [[2]] = 5 LIMITS none LINK LIBRARY none SEE ALSO append, insert, islist, pop, push, remove, rsearch, search, select, size ## Copyright (C) 1999-2006 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: delete,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/delete,v $ ## ## Under source code control: 1994/03/19 03:13:18 ## File existed as early as: 1994 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ Calc generated error codes (see the error help file): ## 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: errorcodes.hdr,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/errorcodes.hdr,v $ ## ## Under source code control: 1995/12/18 03:19:11 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ 10001 Division by zero 10002 Indeterminate (0/0) 10003 Bad arguments for + 10004 Bad arguments for binary - 10005 Bad arguments for * 10006 Bad arguments for / 10007 Bad argument for unary - 10008 Bad argument for squaring 10009 Bad argument for inverse 10010 Bad argument for ++ 10011 Bad argument for -- 10012 Bad argument for int 10013 Bad argument for frac 10014 Bad argument for conj 10015 Bad first argument for appr 10016 Bad second argument for appr 10017 Bad third argument for appr 10018 Bad first argument for round 10019 Bad second argument for round 10020 Bad third argument for round 10021 Bad first argument for bround 10022 Bad second argument for bround 10023 Bad third argument for bround 10024 Bad first argument for sqrt 10025 Bad second argument for sqrt 10026 Bad third argument for sqrt 10027 Bad first argument for root 10028 Bad second argument for root 10029 Bad third argument for root 10030 Bad argument for norm 10031 Bad first argument for << or >> 10032 Bad second argument for << or >> 10033 Bad first argument for scale 10034 Bad second argument for scale 10035 Bad first argument for ^ 10036 Bad second argument for ^ 10037 Bad first argument for power 10038 Bad second argument for power 10039 Bad third argument for power 10040 Bad first argument for quo or // 10041 Bad second argument for quo or // 10042 Bad third argument for quo 10043 Bad first argument for mod or % 10044 Bad second argument for mod or % 10045 Bad third argument for mod 10046 Bad argument for sgn 10047 Bad first argument for abs 10048 Bad second argument for abs 10049 Scan error in argument for eval 10050 Non-simple type for str 10051 Non-real epsilon for exp 10052 Bad first argument for exp 10053 Non-file first argument for fputc 10054 Bad second argument for fputc 10055 File not open for writing for fputc 10056 Non-file first argument for fgetc 10057 File not open for reading for fgetc 10058 Non-string arguments for fopen 10059 Unrecognized mode for fopen 10060 Non-file first argument for freopen 10061 Non-string or unrecognized mode for freopen 10062 Non-string third argument for freopen 10063 Non-file argument for fclose 10064 Non-file argument for fflush 10065 Non-file first argument for fputs 10066 Non-string argument after first for fputs 10067 File not open for writing for fputs 10068 Non-file argument for fgets 10069 File not open for reading for fgets 10070 Non-file first argument for fputstr 10071 Non-string argument after first for fputstr 10072 File not open for writing for fputstr 10073 Non-file first argument for fgetstr 10074 File not open for reading for fgetstr 10075 Non-file argument for fgetline 10076 File not open for reading for fgetline 10077 Non-file argument for fgetfield 10078 File not open for reading for fgetfield 10079 Non-file argument for rewind 10080 Non-integer argument for files 10081 Non-string fmt argument for fprint 10082 Stdout not open for writing to ??? 10083 Non-file first argument for fprintf 10084 Non-string second (fmt) argument for fprintf 10085 File not open for writing for fprintf 10086 Non-string first (fmt) argument for strprintf 10087 Error in attempting strprintf ??? 10088 Non-file first argument for fscan 10089 File not open for reading for fscan 10090 Non-string first argument for strscan 10091 Non-file first argument for fscanf 10092 Non-string second (fmt) argument for fscanf 10093 Non-lvalue argument after second for fscanf 10094 File not open for reading or other error for fscanf 10095 Non-string first argument for strscanf 10096 Non-string second (fmt) argument for strscanf 10097 Non-lvalue argument after second for strscanf 10098 Some error in attempting strscanf ??? 10099 Non-string first (fmt) argument for scanf 10100 Non-lvalue argument after first for scanf 10101 Some error in attempting scanf ??? 10102 Non-file argument for ftell 10103 File not open or other error for ftell 10104 Non-file first argument for fseek 10105 Non-integer or negative second argument for fseek 10106 File not open or other error for fseek 10107 Non-file argument for fsize 10108 File not open or other error for fsize 10109 Non-file argument for feof 10110 File not open or other error for feof 10111 Non-file argument for ferror 10112 File not open or other error for ferror 10113 Non-file argument for ungetc 10114 File not open for reading for ungetc 10115 Bad second argument or other error for ungetc 10116 Exponent too big in scanning 10117 E_ISATTY1 is no longer used 10118 E_ISATTY2 is no longer used 10119 Non-string first argument for access 10120 Bad second argument for access 10121 Bad first argument for search 10122 Bad second argument for search 10123 Bad third argument for search 10124 Bad fourth argument for search 10125 Cannot find fsize or fpos for search 10126 File not readable for search 10127 Bad first argument for rsearch 10128 Bad second argument for rsearch 10129 Bad third argument for rsearch 10130 Bad fourth argument for rsearch 10131 Cannot find fsize or fpos for rsearch 10132 File not readable for rsearch 10133 Too many open files 10134 Attempt to rewind a file that is not open 10135 Bad argument type for strerror 10136 Index out of range for strerror 10137 Bad epsilon for cos 10138 Bad first argument for cos 10139 Bad epsilon for sin 10140 Bad first argument for sin 10141 Non-string argument for eval 10142 Bad epsilon for arg 10143 Bad first argument for arg 10144 Non-real argument for polar 10145 Bad epsilon for polar 10146 Non-integral argument for fcnt 10147 Non-variable first argument for matfill 10148 Non-matrix first argument-value for matfill 10149 Non-matrix argument for matdim 10150 Non-matrix argument for matsum 10151 E_ISIDENT is no longer used 10152 Non-matrix argument for mattrans 10153 Non-two-dimensional matrix for mattrans 10154 Non-matrix argument for det 10155 Matrix for det not of dimension 2 10156 Non-square matrix for det 10157 Non-matrix first argument for matmin 10158 Non-positive-integer second argument for matmin 10159 Second argument for matmin exceeds dimension 10160 Non-matrix first argument for matmin 10161 Second argument for matmax not positive integer 10162 Second argument for matmax exceeds dimension 10163 Non-matrix argument for cp 10164 Non-one-dimensional matrix for cp 10165 Matrix size not 3 for cp 10166 Non-matrix argument for dp 10167 Non-one-dimensional matrix for dp 10168 Different-size matrices for dp 10169 Non-string argument for strlen 10170 Non-string argument for strcat 10171 Non-string first argument for strcat 10172 Non-non-negative integer second argument for strcat 10173 Bad argument for char 10174 Non-string argument for ord 10175 Non-list-variable first argument for insert 10176 Non-integral second argument for insert 10177 Non-list-variable first argument for push 10178 Non-list-variable first argument for append 10179 Non-list-variable first argument for delete 10180 Non-integral second argument for delete 10181 Non-list-variable argument for pop 10182 Non-list-variable argument for remove 10183 Bad epsilon argument for ln 10184 Non-numeric first argument for ln 10185 Non-integer argument for error 10186 Argument outside range for error 10187 Attempt to eval at maximum input depth 10188 Unable to open string for reading 10189 First argument for rm is not a non-empty string 10190 Unable to remove a file 10191 Operation allowed because calc mode disallows read operations 10192 Operation allowed because calc mode disallows write operations 10193 Operation allowed because calc mode disallows exec operations 10194 Unordered arguments for min 10195 Unordered arguments for max 10196 Unordered items for minimum of list 10197 Unordered items for maximum of list 10198 Size undefined for argument type 10199 Calc must be run with a -C argument to use custom function 10200 Calc was built with custom functions disabled 10201 Custom function unknown, try: show custom 10202 Non-integral length for block 10203 Negative or too-large length for block 10204 Non-integral chunksize for block 10205 Negative or too-large chunksize for block 10206 Named block does not exist for blkfree 10207 Non-integral id specification for blkfree 10208 Block with specified id does not exist 10209 Block already freed 10210 No-realloc protection prevents blkfree 10211 Non-integer argument for blocks 10212 Non-allocated index number for blocks 10213 Non-integer or negative source index for copy 10214 Source index too large for copy 10215 E_COPY3 is no longer used 10216 Non-integer or negative number for copy 10217 Number too large for copy 10218 Non-integer or negative destination index for copy 10219 Destination index too large for copy 10220 Freed block source for copy 10221 Unsuitable source type for copy 10222 Freed block destinction for copy 10223 Unsuitable destination type for copy 10224 Incompatible source and destination for copy 10225 No-copy-from source variable 10226 No-copy-to destination variable 10227 No-copy-from source named block 10228 No-copy-to destination named block 10229 No-relocate destination for copy 10230 File not open for copy 10231 fseek or fsize failure for copy 10232 fwrite error for copy 10233 fread error for copy 10234 Non-variable first argument for protect 10235 Bad second argument for protect 10236 Bad third argument for protect 10237 No-copy-to destination for matfill 10238 No-assign-from source for matfill 10239 Non-matrix argument for mattrace 10240 Non-two-dimensional argument for mattrace 10241 Non-square argument for mattrace 10242 Bad epsilon for tan 10243 Bad argument for tan 10244 Bad epsilon for cot 10245 Bad argument for cot 10246 Bad epsilon for sec 10247 Bad argument for sec 10248 Bad epsilon for csc 10249 Bad argument for csc 10250 Bad epsilon for sinh 10251 Bad argument for sinh 10252 Bad epsilon for cosh 10253 Bad argument for cosh 10254 Bad epsilon for tanh 10255 Bad argument for tanh 10256 Bad epsilon for coth 10257 Bad argument for coth 10258 Bad epsilon for sech 10259 Bad argument for sech 10260 Bad epsilon for csch 10261 Bad argument for csch 10262 Bad epsilon for asin 10263 Bad argument for asin 10264 Bad epsilon for acos 10265 Bad argument for acos 10266 Bad epsilon for atan 10267 Bad argument for atan 10268 Bad epsilon for acot 10269 Bad argument for acot 10270 Bad epsilon for asec 10271 Bad argument for asec 10272 Bad epsilon for acsc 10273 Bad argument for acsc 10274 Bad epsilon for asin 10275 Bad argument for asinh 10276 Bad epsilon for acosh 10277 Bad argument for acosh 10278 Bad epsilon for atanh 10279 Bad argument for atanh 10280 Bad epsilon for acoth 10281 Bad argument for acoth 10282 Bad epsilon for asech 10283 Bad argument for asech 10284 Bad epsilon for acsch 10285 Bad argument for acsch 10286 Bad epsilon for gd 10287 Bad argument for gd 10288 Bad epsilon for agd 10289 Bad argument for agd 10290 Log of zero or infinity 10291 String addition failure 10292 String multiplication failure 10293 String reversal failure 10294 String subtraction failure 10295 Bad argument type for bit 10296 Index too large for bit 10297 Non-integer second argument for setbit 10298 Out-of-range index for setbit 10299 Non-string first argument for setbit 10300 Bad argument for or 10301 Bad argument for and 10302 Allocation failure for string or 10303 Allocation failure for string and 10304 Bad argument for xorvalue 10305 Bad argument for comp 10306 Allocation failure for string diff 10307 Allocation failure for string comp 10308 Bad first argument for segment 10309 Bad second argument for segment 10310 Bad third argument for segment 10311 Failure for string segment 10312 Bad argument type for highbit 10313 Non-integer argument for highbit 10314 Bad argument type for lowbit 10315 Non-integer argument for lowbit 10316 Bad argument type for unary hash op 10317 Bad argument type for binary hash op 10318 Bad first argument for head 10319 Bad second argument for head 10320 Failure for strhead 10321 Bad first argument for tail 10322 Bad second argument for tail 10323 Failure for strtail 10324 Failure for strshift 10325 Non-string argument for strcmp 10326 Bad argument type for strncmp 10327 Varying types of argument for xor 10328 Bad argument type for xor 10329 Bad argument type for strcpy 10330 Bad argument type for strncpy 10331 Bad argument type for unary backslash 10332 Bad argument type for setminus 10333 Bad first argument type for indices 10334 Bad second argument for indices 10335 Too-large re(argument) for exp 10336 Too-large re(argument) for sinh 10337 Too-large re(argument) for cosh 10338 Too-large im(argument) for sin 10339 Too-large im(argument) for cos 10340 Infinite or too-large result for gd 10341 Infinite or too-large result for agd 10342 Too-large value for power 10343 Too-large value for root 10344 Non-real first arg for digit 10345 Non-integral second arg for digit 10346 Bad third arg for digit 10347 Bad first argument for places 10348 Bad second argument for places 10349 Bad first argument for digits 10350 Bad second argument for digits 10351 Bad first argument for ilog 10352 Bad second argument for ilog 10353 Bad argument for ilog10 10354 Bad argument for ilog2 10355 Non-integer second arg for comb 10356 Too-large second arg for comb 10357 Bad argument for catalan 10358 Bad argument for bern 10359 Bad argument for euler 10360 Bad argument for sleep 10361 calc_tty failure 10362 No-copy-to destination for octet assign 10363 No-copy-from source for octet assign 10364 No-change destination for octet assign 10365 Non-variable destination for assign 10366 No-assign-to destination for assign 10367 No-assign-from source for assign 10368 No-change destination for assign 10369 No-type-change destination for assign 10370 No-error-value destination for assign 10371 No-copy argument for octet swap 10372 No-assign-to-or-from argument for swap 10373 Non-lvalue argument for swap 10374 Non-lvalue argument 3 or 4 for quomod 10375 Non-real-number arg 1 or 2 or bad arg 5 for quomod 10376 No-assign-to argument 3 or 4 for quomod 10377 No-copy-to or no-change argument for octet preinc 10378 Non-variable argument for preinc 10379 No-assign-to or no-change argument for preinc 10380 No-copy-to or no-change argument for octet predec 10381 Non-variable argument for predec 10382 No-assign-to or no-change argument for predec 10383 No-copy-to or no-change argument for octet postinc 10384 Non-variable argument for postinc 10385 No-assign-to or no-change argument for postinc 10386 No-copy-to or no-change argument for octet postdec 10387 Non-variable argument for postdec 10388 No-assign-to or no-change argument for postdec 10389 Error-type structure for initialization 10390 No-copy-to structure for initialization 10391 Too many initializer values 10392 Attempt to initialize freed named block 10393 Bad structure type for initialization 10394 No-assign-to element for initialization 10395 No-change element for initialization 10396 No-type-change element for initialization 10397 No-error-value element for initialization 10398 No-assign-or-copy-from source for initialization 10399 No-relocate for list insert 10400 No-relocate for list delete 10401 No-relocate for list push 10402 No-relocate for list append 10403 No-relocate for list pop 10404 No-relocate for list remove 10405 Non-variable first argument for modify 10406 Non-string second argument for modify 10407 No-change first argument for modify 10408 Undefined function for modify 10409 Unacceptable type first argument for modify 10410 Non-string arguments for fpathopen 10411 Unrecognized mode for fpathopen 10412 Bad epsilon argument for log 10413 Non-numeric first argument for log 10414 Non-file argument for fgetfile 10415 File argument for fgetfile not open for reading 10416 Unable to set file position in fgetfile 10417 Non-representable type for estr 20000 base of user defined errors NAME isconfig - whether a value is a configuration state SYNOPSIS isconfig(x) TYPES x any, &any return int DESCRIPTION Determine if x is a configuration state. This function will return 1 if x is a file, 0 otherwise. EXAMPLE ; a = config("all") ; print isconfig(a), isconfig(0); 1 0 LIMITS none LINK LIBRARY none SEE ALSO config, isassoc, isatty, isblk, isdefined, iserror, iseven, isfile, ishash, isident, isint, islist, ismat, ismult, isnull, isnum, isobj, isobjtype, isodd, isprime, isrand, israndom, isreal, isrel, issimple, issq, isstr, istype ## 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: isconfig,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/isconfig,v $ ## ## Under source code control: 1995/11/11 05:09:41 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME sgn - indicator of sign of a real or complex number SYNOPSIS sgn(x) TYPES x real or complex return -1, 0, 1 (real) -1, 0, 1, -1+1i, 1i, 1+1i, -1-1i, -1i or 1-1i (complex) DESCRIPTION Return the value of cmp(a,0). For real x, sgn(x) returns: -1 if x < 0 0 if x == 9 1 if x > 0 For complex, sgn(x) returns: sgn(re(x)) + sgn(im(x))*1i EXAMPLE ; print sgn(27), sgn(1e-20), sgn(0), sgn(-45) 1 1 0 -1 ; print sgn(2+3i), sgn(6i), sgn(-7+4i), sgn(-6), sgn(-6-3i), sgn(-2i) 1+1i 1i -1+1i -1 -1-1i -1i LIMITS none LINK LIBRARY NUMBER *qsign(NUMBER *x) SEE ALSO abs ## 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. ## ## @(#) $Revision: 30.2 $ ## @(#) $Id: sgn,v 30.2 2008/05/10 13:23:57 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sgn,v $ ## ## Under source code control: 1995/10/25 04:03:46 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME mod - compute the remainder for an integer quotient SYNOPSIS mod(x, y, rnd) x % y TYPES If x is a matrix or list, the returned value is a matrix or list v of the same structure for which each element v[[i]] = mod(x[[i]], y, rnd). If x is an xx-object or x is not an object and y is an xx-object, this function calls the user-defined function xx_mod(x, y, rnd); the types of arguments and returned value are as required by the definition of xx_mod(). If neither x nor y is an object, or x is not a matrix or list: x number (real or complex) y real rnd integer, defaults to config("mod") return number DESCRIPTION The expression: x % y is equivalent to call: mod(x, y) The function: mod(x, y, rnd) is equivalent to: config("mod", rnd), x % y except that the global config("mod") value does not change. If x is real or complex and y is zero, mod(x, y, rnd) returns x. If x is complex, mod(x, y, rnd) returns mod(re(x), y, rnd) + mod(im(x), y, rnd) * 1i. In the following it is assumed x is real and y is nonzero. If x/y is an integer mod(x, y, rnd) returns zero. If x/y is not an integer, mod(x, y, rnd) returns one of the two values of r for which for some integer q exists such that x = q * y + r and abs(r) < abs(y). Which of the two values or r that is returned is controlled by rnd. If bit 4 of rnd is set (e.g. if 16 <= rnd < 32) abs(r) <= abs(y)/2; this uniquely determines r if abs(r) < abs(y)/2. If bit 4 of rnd is set and abs(r) = abs(y)/2, or if bit 4 of r is not set, the result for r depends on rnd as in the following table: rnd & 15 sign of r parity of q 0 sgn(y) 1 -sgn(y) 2 sgn(x) 3 -sgn(x) 4 + 5 - 6 sgn(x/y) 7 -sgn(x/y) 8 even 9 odd 10 even if x/y > 0, otherwise odd 11 odd if x/y > 0, otherwise even 12 even if y > 0, otherwise odd 13 odd if y > 0, otherwise even 14 even if x > 0, otherwise odd 15 odd if x > 0, otherwise even NOTE: Blank entries in the table above indicate that the description would be complicated and probably not of much interest. The C language method of modulus and integer division is: config("quomod", 2) config("quo", 2) config("mod", 2) This dependence on rnd is consistent with quo(x, y, rnd) and appr(x, y, rnd) in that for any real x and y and any integer rnd, x = y * quo(x, y, rnd) + mod(x, y, rnd). mod(x, y, rnd) = x - appr(x, y, rnd) If y and rnd are fixed and mod(x, y, rnd) is to be considered as a canonical residue of x % y, bits 1 and 3 of rnd should be zero: if 0 <= rnd < 32, it is only for rnd = 0, 1, 4, 5, 16, 17, 20, or 21, that the set of possible values for mod(x, y, rnd) form an interval of length y, and for any x1, x2, mod(x1, y, rnd) = mod(x2, y, rnd) is equivalent to: x1 is congruent to x2 modulo y. This is particularly relevant when working with the ring of integers modulo an integer y. EXAMPLE ; print mod(11,5,0), mod(11,5,1), mod(-11,5,2), mod(-11,-5,3) 1 -4 -1 4 ; print mod(12.5,5,16), mod(12.5,5,17), mod(12.5,5,24), mod(-7.5,-5,24) 2.5 -2.5 2.5 2.5 ; A = list(11,13,17,23,29) ; print mod(A,10,0) list (5 elements, 5 nonzero): [[0]] = 1 [[1]] = 3 [[2]] = 7 [[3]] = 3 [[4]] = 9 LIMITS none LINK LIBRARY void modvalue(VALUE *x, VALUE *y, VALUE *rnd, VALUE *result) NUMBER *qmod(NUMBER *y, NUMBER *y, long rnd) SEE ALSO quo, quomod, //, % ## Copyright (C) 1999-2006 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: mod,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/mod,v $ ## ## Under source code control: 1995/09/18 02:09:31 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME popcnt - number of bit that match a given value SYNOPSIS popcnt(x [,bitval]) TYPES x number (real or integer) bitval 0 or 1 return number DESCRIPTION Count the number of bits in abs(x) that match bitval. The default bitval is 1 which counts the number of 1 bits. The popcnt function is equivalent to #x when x is an integer. EXAMPLE ; print popcnt(32767), popcnt(3/2), popcnt(pi(),0), popcnt(pi(),1) 15 3 69 65 ; print popcnt(randombit(128), 0), popcnt(randombit(128), 1) 61 64 LIMITS none LINK LIBRARY long zpopcnt(ZVALUE z, int bitval) SEE ALSO none ## 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: popcnt,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/popcnt,v $ ## ## Under source code control: 1997/09/11 04:20:02 ## File existed as early as: 1997 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ Using objects Objects are user-defined types which are associated with user- defined functions to manipulate them. Object types are defined similarly to structures in C, and consist of one or more elements. The advantage of an object is that the user-defined routines are automatically called by the calculator for various operations, such as addition, multiplication, and printing. Thus they can be manipulated by the user as if they were just another kind of number. An example object type is "surd", which represents numbers of the form a + b*sqrt(D), where D is a fixed integer, and 'a' and 'b' are arbitrary rational numbers. Addition, subtraction, multiplication, and division can be performed on such numbers, and the result can be put unambiguously into the same form. (Complex numbers are an example of surds, where D is -1.) The "obj" statement defines either an object type or an actual variable of that type. When defining the object type, the names of its elements are specified inside of a pair of braces. To define the surd object type, the following could be used: obj surd {a, b}; Here a and b are the element names for the two components of the surd object. An object type can be defined more than once as long as the number of elements and their names are the same. When an object is created, the elements are all defined with zero values. A user-defined routine should be provided which will place useful values in the elements. For example, for an object of type 'surd', a function called 'surd' can be defined to set the two components as follows: define surd(a, b) { local x; obj surd x; x.a = a; x.b = b; return x; } When an operation is attempted for an object, user functions with particular names are automatically called to perform the operation. These names are created by concatenating the object type name and the operation name together with an underscore. For example, when multiplying two objects of type surd, the function "surd_mul" is called. The user function is called with the necessary arguments for that operation. For example, for "surd_mul", there are two arguments, which are the two numbers. The order of the arguments is always the order of the binary operands. If only one of the operands to a binary operator is an object, then the user function for that object type is still called. If the two operands are of different object types, then the user function that is called is the one for the first operand. The above rules mean that for full generality, user functions should detect that one of their arguments is not of its own object type by using the 'istype' function, and then handle these cases specially. In this way, users can mix normal numbers with object types. (Functions which only have one operand don't have to worry about this.) The following example of "surd_mul" demonstrates how to handle regular numbers when used together with surds: define surd_mul(a, b) { local x; obj surd x; if (!istype(a, x)) { /* a not of type surd */ x.a = b.a * a; x.b = b.b * a; } else if (!istype(b, x)) { /* b not of type surd */ x.a = a.a * b; x.b = a.b * b; } else { /* both are surds */ x.a = a.a * b.a + D * a.b * b.b; x.b = a.a * b.b + a.b * b.a; } if (x.b == 0) return x.a; /* normal number */ return x; /* return surd */ } In order to print the value of an object nicely, a user defined routine can be provided. For small amounts of output, the print routine should not print a newline. Also, it is most convenient if the printed object looks like the call to the creation routine. For output to be correctly collected within nested output calls, output should only go to stdout. This means use the 'print' statement, the 'printf' function, or the 'fprintf' function with 'files(1)' as the output file. For example, for the "surd" object: define surd_print(a) { print "surd(" : a.a : "," : a.b : ")" : ; } It is not necessary to provide routines for all possible operations for an object, if those operations can be defaulted or do not make sense for the object. The calculator will attempt meaningful defaults for many operations if they are not defined. For example, if 'surd_square' is not defined to square a number, then 'surd_mul' will be called to perform the squaring. When a default is not possible, then an error will be generated. Please note: Arguments to object functions are always passed by reference (as if an '&' was specified for each variable in the call). Therefore, the function should not modify the parameters, but should copy them into local variables before modifying them. This is done in order to make object calls quicker in general. The double-bracket operator can be used to reference the elements of any object in a generic manner. When this is done, index 0 corresponds to the first element name, index 1 to the second name, and so on. The 'size' function will return the number of elements in an object. The following is a list of the operations possible for objects. The 'xx' in each function name is replaced with the actual object type name. This table is displayed by the 'show objfunctions' command. Name Args Comments xx_print 1 print value, default prints elements xx_one 1 multiplicative identity, default is 1 xx_test 1 logical test (false,true => 0,1), default tests elements xx_add 2 xx_sub 2 xx_neg 1 negative xx_mul 2 xx_div 2 non-integral division xx_inv 1 multiplicative inverse xx_abs 2 absolute value within given error xx_norm 1 square of absolute value xx_conj 1 conjugate xx_pow 2 integer power, default does multiply, square, inverse xx_sgn 1 sign of value (-1, 0, 1) xx_cmp 2 equality (equal,nonequal => 0,1), default tests elements xx_rel 2 relative order, positive for >, etc. xx_quo 3 integer quotient xx_mod 3 remainder of division xx_int 1 integer part xx_frac 1 fractional part xx_inc 1 increment, default adds 1 xx_dec 1 decrement, default subtracts 1 xx_square 1 default multiplies by itself xx_scale 2 multiply by power of 2 xx_shift 2 shift left by n bits (right if negative) xx_round 3 round to given number of decimal places xx_bround 3 round to given number of binary places xx_root 3 root of value within given error xx_sqrt 3 square root within given error xx_or 2 bitwise or xx_and 2 bitwise and xx_not 1 logical not xx_fact 1 factorial or postfix ! xx_min 1 value for min(...) xx_max 1 value for max(...) xx_sum 1 value for sum(...) xx_assign 2 assign, defaults to a = b xx_xor 2 value for binary ~ xx_comp 1 value for unary ~ xx_content 1 unary hash op xx_hashop 2 binary hash op xx_backslash 1 unary backslash op xx_setminus 2 binary backslash op xx_plus 1 unary + op Also see the standard resource files: deg.cal dms.cal ellip.cal hms.cal mod.cal natnumset.cal poly.cal quat.cal regress.cal set8700.cal surd.cal test2300.cal test3100.cal ## Copyright (C) 1999,2010 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. ## ## @(#) $Revision: 30.3 $ ## @(#) $Id: obj.file,v 30.3 2010/09/02 06:36:21 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/obj.file,v $ ## ## Under source code control: 1991/07/21 04:37:22 ## File existed as early as: 1991 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME cp - cross product of two 3 element vectors SYNOPSIS cp(x, y) TYPES x, y 1-dimensional matrices with 3 elements return 1-dimensional matrix with 3 elements DESCRIPTION Calculate the product of two 3 1-dimensional matrices. If x has elements (x0, x1, x2), and y has elements (y0, y1, y2), cp(x,y) returns the matrix of type [0:2] with elements: {x1 * y2 - x2 * y1, x3 * y1 - x1 * y3, x1 * y2 - x2 * y1} EXAMPLE ; mat x[3] = {2,3,4} ; mat y[3] = {3,4,5} ; print cp(x,y) mat [3] (3 elements, 3 nonzero): [0] = -1 [1] = 2 [2] = -1 LIMITS The components of the matrices are to be of types for which the required algebraic operations have been defined. LINK LIBRARY MATRIX *matcross(MATRIX *x, MATRIX *y) SEE ALSO dp ## 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: 30.1 $ ## @(#) $Id: cp,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/cp,v $ ## ## Under source code control: 1995/10/05 04:52:26 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME lcm - least common multiple of a set of rational numbers SYNOPSIS lcm(x1, x2, ...) TYPES x1, x2, ... rational number return rational number DESCRIPTION Compute the least common multiple of one or more rational numbers. If no xi is zero, lcm(x1, x2, ...) is the least positive number v for which v is a multiple of each xi. If at least one xi is zero, the lcm is zero. EXAMPLE ; print lcm(12, -24, 30), lcm(9/10, 11/5, 4/25), lcm(2) -120 79.2 2 LIMITS The number of arguments is not to exceed 1024. LINK LIBRARY NUMBER *qlcm(NUMBER *x1, NUMBER *x2) SEE ALSO gcd ## Copyright (C) 1999-2006 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: lcm,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/lcm,v $ ## ## Under source code control: 1995/10/05 04:52:26 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME scan - scan standard input for possible assignment to variables SYNOPSIS scan(x_1, x_2, ..., x_n) TYPES x_1, x_2, ... any return integer DESCRIPTION When input is from a terminal, execution is halted and input is read until a newline is entered. Strings of non-whitespace characters are evaluated in succession and if the corresponding x_i is an lvalue, the resulting value is assigned to x_i. If the number of strings read exceeds n, only the first n strings are evaluated. If the number of strings is less than n, the later x_i are ignored. EXAMPLE ; global a, b, c, d; ; scan(a, 0, c, d) ; 2+3 b=a^2 3+4i 3+"a" ; print a,b,c,d 5 25 3+4i Error 3 LIMITS The number of arguments is not to exceed 1024. LINK LIBRARY int scanfstr(char *str, char *fmt, int count, VALUE **vals); SEE ALSO fscan, strscan, fscanf, strscanf, scanf, printf, fprintf ## Copyright (C) 1999-2006 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: scan,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/scan,v $ ## ## Under source code control: 1996/04/30 03:05:18 ## File existed as early as: 1996 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME errmax - return or set maximum error-count before execution stops SYNOPSIS errmax([num]) TYPES num integer return integer DESCRIPTION Without an argument, errmax() returns the current value of an internal variable errmax. Calling errmax(num) returns this value but then resets its value to num. Execution is aborted if evaluation of an error value if this makes errcount > errmax and errmax is >= 0. When errmax is -1, there is no limit on the number of errors. EXAMPLE ; errmax(2) 0 ; errcount() 0 ; a = 1/0; b = 2 + ""; c = error(27); d = newerror("alpha"); Error 27 caused errcount to exceed errmax ## Here global variables c and d were created when compiling the line ## but execution was aborted before the intended assignments to c and d. ; print c, d 0 0 ; errmax(-1) 2 LIMITS -1 <= num <= 2147483647 LINK LIBRARY none SEE ALSO errcount, error, strerror, iserror, errno, newerror, errorcodes, stoponerror ## Copyright (C) 2006 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. ## ## @(#) $Revision: 30.1 $ ## @(#) $Id: errmax,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/errmax,v $ ## ## Under source code control: 1997/03/08 08:51:14 ## File existed as early as: 1997 ## ## c