ibrary and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! NAME minv - inverse of an integer modulo a specified integer SYNOPSIS minv(x, md) TYPES x integer md integer return integer DESCRIPTION If x and md are not relatively prime, zero is returned. Otherwise v = minv(x, md) is the canonical residue v modulo md for which v * x is congruent to 1 modulo md. The canonical residues modulo md are determined as follows by md and bits 0, 2 and 4 of config("mod") (other bits are ignored). config("mod") md > 0 md < 0 0 0 < v < md md < v < 0 1 -md < v < 0 0 < v < -md 4 0 < v < md 0 < v < -md 5 -md < v < 0 md < v < 0 16 -md/2 < v <= md/2 md/2 <= v < -md/2 17 -md/2 <= v < md/2 md/2 < v <= -md/2 20 -md/2 < v <= md/2 md/2 < v <= -md/2 21 -md/2 <= v < md/2 md/2 <= v < -md/2 EXAMPLE ; c = config("mod", 0) ; print minv(3,10), minv(-3,10), minv(3,-10), minv(-3,-10), minv(4,10) 7 3 -3 -7 0 ; c = config("mod",16) ; print minv(3,10), minv(-3,10), minv(3,-10), minv(-3,-10), minv(4,10) -3 3 -3 3 0 LIMITS none LINK LIBRARY NUMBER *qminv(NUMBER *x, NUMBER *md) SEE ALSO mod, pmod ## 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: minv,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/minv,v $ ## ## Under source code control: 1995/11/09 03:27:51 ## 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 randbit - additive 55 shuffle pseudo-random number generator SYNOPSIS randbit([x]) TYPES x integer return integer DESCRIPTION If x > 0, randbit(x) returns a pseudo-random integer in [0, 2^x), i.e. the same as rand(2^x). If the integer returned is b_1 * 2^(x-1) + b_2 * 2^(x-2) + ... + b_n, where each b_i is 0 or 1, then b_1, b_2, ..., b_n may be considered as a sequence of x random bits. If x <= 0, randbit(x) causes the random-number generator to skip abs(x) bits, and returns abs(x). If x is omitted, it is assumed to have the value of 1. See the rand() help page for details on the additive 55 shuffle pseudo-random number generator. EXAMPLE ; print srand(0), randbit(20), randbit(20), randbit(20), randbit(20) RAND state 817647 476130 944201 822573 ; print srand(0), randbit(-20), randbit(20), randbit(-20), randbit(20) RAND state 20 476130 20 822573 LIMITS x != 0 LINK LIBRARY void zrand(long cnt, ZVALUE *res) SEE ALSO seed, srand, randbit, isrand, random, srandom, israndom ## 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: randbit,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/randbit,v $ ## ## Under source code control: 1996/01/01 03:17:22 ## 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 islist - whether a value is a list SYNOPSIS islist(x) TYPES x any, &any return int DESCRIPTION Determine if x is a list. This function will return 1 if x is a list, 0 otherwise. EXAMPLE ; lst = list(2,3,4) ; print islist(lst), islist(1) 1 0 LIMITS none LINK LIBRARY none SEE ALSO append, delete, insert, pop, push, remove, rsearch, search, select, size, isassoc, isatty, isblk, isconfig, isdefined, iserror, iseven, isfile, ishash, isident, isint, ismat, ismult, isnull, isnum, isobj, isobjtype, isodd, isprime, isrand, israndom, isreal, isrel, issimple, issq, isstr, istype ## 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: islist,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/islist,v $ ## ## Under source code control: 1994/03/19 03:13:19 ## File existed as early as: 1994 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME abs - absolute value SYNOPSIS abs(x [,eps]) TYPES If x is an object of type xx, the function xx_abs has to have been defined; this will determine the types for x, eps and the returned value. For non-object x and eps: x number (real or complex) eps ignored if x is real, nonzero real for complex x, defaults to epsilon(). return non-negative real DESCRIPTION If x is real, returns the absolute value of x, i.e. x if x >= 0, -x if x < 0. For complex x with zero real part, returns the absolute value of im(x). For other complex x, returns the multiple of eps nearest to the absolute value of x, or in the case of two equally near nearest values, the the nearest even multiple of eps. In particular, with eps = 10^-n, the result will be the absolute value correct to n decimal places. EXAMPLE ; print abs(3.4), abs(-3.4) 3.4 3.4 ; print abs(3+4i, 1e-5), abs(4+5i, 1e-5), abs(4+5i, 1e-10) 5 6.40312 6.4031242374 LIMITS none LINK LIBRARY NUMBER *qqabs(NUMBER *x) SEE ALSO cmp, epsilon, hypot, norm, near, obj ## 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: abs,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/abs,v $ ## ## Under source code control: 1994/03/19 01:40:22 ## 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 standard resource files ---------------------------- To load a resource file, try: read filename You do not need to add the .cal extension to the filename. Calc will search along the $CALCPATH (see ``help environment''). Normally a resource file will simply define some functions. By default, most resource files will print out a short message when they are read. For example: ; read lucas lucas(h,n) defined gen_u0(h,n,v1) defined gen_v1(h,n) defined ldebug(funct,str) defined will cause calc to load and execute the 'lucas.cal' resource file. Executing the resource file will cause several functions to be defined. Executing the lucas function: ; lucas(149,60) 1 ; lucas(146,61) 0 shows that 149*2^60-1 is prime whereas 146*2^61-1 is not. =-= Calc resource file files are provided because they serve as examples of how use the calc language, and/or because the authors thought them to be useful! If you write something that you think is useful, please send it to: calc-contrib at asthe dot com [[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]] [[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]] By convention, a resource file only defines and/or initializes functions, objects and variables. (The regress.cal and testxxx.cal regression test suite is an exception.) Also by convention, an additional usage message regarding important object and functions is printed. If a resource file needs to load another resource file, it should use the -once version of read: /* pull in needed resource files */ read -once "surd" read -once "lucas" This will cause the needed resource files to be read once. If these files have already been read, the read -once will act as a noop. The "resource_debug" parameter is intended for controlling the possible display of special information relating to functions, objects, and other structures created by instructions in calc resource files. Zero value of config("resource_debug") means that no such information is displayed. For other values, the non-zero bits which currently have meanings are as follows: n Meaning of bit n of config("resource_debug") 0 When a function is defined, redefined or undefined at interactive level, a message saying what has been done is displayed. 1 When a function is defined, redefined or undefined during the reading of a file, a message saying what has been done is displayed. 2 Show func will display more information about a functions arguments as well as more argument summary information. 3 During execution, allow calc standard resource files to output additional debugging information. The value for config("resource_debug") in both oldstd and newstd is 3, but if calc is invoked with the -d flag, its initial value is zero. Thus, if calc is started without the -d flag, until config("resource_debug") is changed, a message will be output when a function is defined either interactively or during the reading of a file. Sometimes the information printed is not enough. In addition to the standard information, one might want to print: * useful obj definitions * functions with optional args * functions with optional args where the param() interface is used For these cases we suggest that you place at the bottom of your code something that prints extra information if config("resource_debug") has either of the bottom 2 bits set: if (config("resource_debug") & 3) { print "obj xyz defined"; print "funcA([val1 [, val2]]) defined"; print "funcB(size, mass, ...) defined"; } If your the resource file needs to output special debugging information, we recommend that you check for bit 3 of the config("resource_debug") before printing the debug statement: if (config("resource_debug") & 8) { print "DEBUG: This a sample debug statement"; } =-= The following is a brief description of some of the calc resource files that are shipped with calc. See above for example of how to read in and execute these files. alg_config.cal global test_time mul_loop(repeat,x) defined mul_ratio(len) defined best_mul2() defined sq_loop(repeat,x) defined sq_ratio(len) defined best_sq2() defined pow_loop(repeat,x,ex) defined pow_ratio(len) defined best_pow2() defined These functions search for an optimal value of config("mul2"), config("sq2"), and config("pow2"). The calc default values of these configuration values were set by running this resource file on a 1.8GHz AMD 32-bit CPU of ~3406 BogoMIPS. The best_mul2() function returns the optimal value of config("mul2"). The best_sq2() function returns the optimal value of config("sq2"). The best_pow2() function returns the optimal value of config("pow2"). The other functions are just support functions. By design, best_mul2(), best_sq2(), and best_pow2() take a few minutes to run. These functions increase the number of times a given computational loop is executed until a minimum amount of CPU time is consumed. To watch these functions progress, one can set the config("user_debug") value. Here is a suggested way to use this resource file: ; read alg_config ; config("user_debug",2),; ; best_mul2(); best_sq2(); best_pow2(); ; best_mul2(); best_sq2(); best_pow2(); ; best_mul2(); best_sq2(); best_pow2(); NOTE: It is perfectly normal for the optimal value returned to differ slightly from run to run. Slight variations due to inaccuracy in CPU timings will cause the best value returned to differ slightly from run to run. One can use a calc startup file to change the initial values of config("mul2"), config("sq2"), and config("pow2"). For example one can place into ~/.calcrc these lines: config("mul2", 1780),; config("sq2", 3388),; config("pow2", 176),; to automatically and silently change these config values. See help/config and CALCRC in help/environment for more information. beer.cal Calc's contribution to the 99 Bottles of Beer web page: http://www.ionet.net/~timtroyr/funhouse/beer.html#calc NOTE: This resource produces a lot of output. :-) bernoulli.cal B(n) Calculate the nth Bernoulli number. NOTE: There is now a bernoulli() builtin function. This file is left here for backward compatibility and now simply returns the builtin function. bigprime.cal bigprime(a, m, p) A prime test, base a, on p*2^x+1 for even x>m. chi.cal Z(x[, eps]) P(x[, eps]) chi_prob(chi_sq, v[, eps]) Computes the Probability, given the Null Hypothesis, that a given Chi squared values >= chi_sq with v degrees of freedom. The chi_prob() function does not work well with odd degrees of freedom. It is reasonable with even degrees of freedom, although one must give a sufficiently small error term as the degrees gets large (>100). The Z(x) and P(x) are internal statistical functions. eps is an optional epsilon() like error term. chrem.cal chrem(r1,m1 [,r2,m2, ...]) chrem(rlist, mlist) Chinese remainder theorem/problem solver. deg.cal deg(deg, min, sec) deg_add(a, b) deg_neg(a) deg_sub(a, b) deg_mul(a, b) deg_print(a) Calculate in degrees, minutes, and seconds. For a more functional version see dms.cal. dms.cal dms(deg, min, sec) dms_add(a, b) dms_neg(a) dms_sub(a, b) dms_mul(a, b) dms_print(a) dms_abs(a) dms_norm(a) dms_test(a) dms_int(a) dms_frac(a) dms_rel(a,b) dms_cmp(a,b) dms_inc(a) dms_dec(a) Calculate in degrees, minutes, and seconds. Unlike deg.cal, increments are on the arc second level. See also hms.cal. dotest.cal dotest(dotest_file [,dotest_code [,dotest_maxcond]]) dotest_file Search along CALCPATH for dotest_file, which contains lines that should evaluate to 1. Comment lines and empty lines are ignored. Comment lines should use ## instead of the multi like /* ... */ because lines are evaluated one line at a time. dotest_code Assign the code number that is to be printed at the start of each non-error line and after **** in each error line. The default code number is 999. dotest_maxcond The maximum number of error conditions that may be detected. An error condition is not a sign of a problem, in some cases a line deliberately forces an error condition. A value of -1, the default, implies a maximum of 2147483647. Global variables and functions must be declared ahead of time because the dotest scope of evaluation is a line at a time. For example: read dotest.cal read set8700.cal dotest("set8700.line"); ellip.cal efactor(iN, ia, B, force) Attempt to factor using the elliptic functions: y^2 = x^3 + a*x + b. hello.cal Calc's contribution to the Hello World! page: http://www.latech.edu/~acm/HelloWorld.shtml http://www.latech.edu/~acm/helloworld/calc.html NOTE: This resource produces a lot of output. :-) hms.cal hms(hour, min, sec) hms_add(a, b) hms_neg(a) hms_sub(a, b) hms_mul(a, b) hms_print(a) hms_abs(a) hms_norm(a) hms_test(a) hms_int(a) hms_frac(a) hms_rel(a,b) hms_cmp(a,b) hms_inc(a) hms_dec(a) Calculate in hours, minutes, and seconds. See also dmscal. intfile.cal file2be(filename) Read filename and return an integer that is built from the octets in that file in Big Endian order. The first octets of the file become the most significant bits of the integer. file2le(filename) Read filename and return an integer that is built from the octets in that file in Little Endian order. The first octets of the file become the most significant bits of the integer. be2file(v, filename) Write the absolute value of v into filename in Big Endian order. The v argument must be on integer. The most significant bits of the integer become the first octets of the file. le2file(v, filename) Write the absolute value of v into filename in Little Endian order. The v argument must be on integer. The least significant bits of the integer become the last octets of the file. linear.cal linear(x0, y0, x1, y1, x) Returns the value y such that (x,y) in on the line (x0,y0), (x1,y1). Requires x0 != y0. lucas.cal lucas(h, n) Perform a primality test of h*2^n-1, with 1<=h<2*n. lucas_chk.cal lucas_chk(high_n) Test all primes of the form h*2^n-1, with 1<=h<200 and n <= high_n. Requires lucas.cal to be loaded. The highest useful high_n is 1000. Used by regress.cal during the 2100 test set. lucas_tbl.cal Lucasian criteria for primality tables. mersenne.cal mersenne(p) Perform a primality test of 2^p-1, for prime p>1. mfactor.cal mfactor(n [, start_k=1 [, rept_loop=10000 [, p_elim=17]]]) Return the lowest factor of 2^n-1, for n > 0. Starts looking for factors at 2*start_k*n+1. Skips values that are multiples of primes <= p_elim. By default, start_k == 1, rept_loop = 10000 and p_elim = 17. The p_elim == 17 overhead takes ~3 minutes on an 200 Mhz r4k CPU and requires about ~13 Megs of memory. The p_elim == 13 overhead takes about 3 seconds and requires ~1.5 Megs of memory. The value p_elim == 17 is best for long factorizations. It is the fastest even thought the initial startup overhead is larger than for p_elim == 13. mod.cal lmod(a) mod_print(a) mod_one() mod_cmp(a, b) mod_rel(a, b) mod_add(a, b) mod_sub(a, b) mod_neg(a) mod_mul(a, b) mod_square(a) mod_inc(a) mod_dec(a) mod_inv(a) mod_div(a, b) mod_pow(a, b) Routines to handle numbers modulo a specified number. natnumset.cal isset(a) setbound(n) empty() full() isin(a, b) addmember(a, n) rmmember(a, n) set() mkset(s) primes(a, b) set_max(a) set_min(a) set_not(a) set_cmp(a, b) set_rel(a, b) set_or(a, b) set_and(a, b) set_comp(a) set_setminus(a, b) set_diff(a,b) set_content(a) set_add(a, b) set_sub(a, b) set_mucËdËeËfËgËhËiËjËkËlËmËnËoËpËqËl(a, b) set_square(a) set_pow(a, n) set_sum(a) set_plus(a) interval(a, b) isinterval(a) set_mod(a, b) randset(n, a, b) polyvals(L, A) polyvals2(L, A, B) set_print(a) Demonstration of how the string operators and functions may be used for defining and working with sets of natural numbers not exceeding a user-specified bound. pell.cal pellx(D) pell(D) Solve Pell's equation; Returns the solution X to: X^2 - D * Y^2 = 1. Type the solution to Pell's equation for a particular D. pi.cal qpi(epsilon) piforever() The qpi() calculate pi within the specified epsilon using the quartic convergence iteration. The piforever() prints digits of pi, nicely formatted, for as long as your free memory space and system up time allows. The piforever() function (written by Klaus Alexander Seistrup ) was inspired by an algorithm conceived by Lambert Meertens. See also the ABC Programmer's Handbook, by Geurts, Meertens & Pemberton, published by Prentice-Hall (UK) Ltd., 1990. pix.cal pi_of_x(x) Calculate the number of primes < x using A(n+1)=A(n-1)+A(n-2). This is a SLOW painful method ... the builtin pix(x) is much faster. Still, this method is interesting. pollard.cal pfactor(N, N, ai, af) Factor using Pollard's p-1 method. poly.cal Calculate with polynomials of one variable. There are many functions. Read the documentation in the resource file. prompt.cal adder() showvalues(str) Demonstration of some uses of prompt() and eval(). psqrt.cal psqrt(u, p) Calculate square roots modulo a prime qtime.cal qtime(utc_hr_offset) Print the time as English sentence given the hours offset from UTC. quat.cal quat(a, b, c, d) quat_print(a) quat_norm(a) quat_abs(a, e) quat_conj(a) quat_add(a, b) quat_sub(a, b) quat_inc(a) quat_dec(a) quat_neg(a) quat_mul(a, b) quat_div(a, b) quat_inv(a) quat_scale(a, b) quat_shift(a, b) Calculate using quaternions of the form: a + bi + cj + dk. In these functions, quaternions are manipulated in the form: s + v, where s is a scalar and v is a vector of size 3. randbitrun.cal randbitrun([run_cnt]) Using randbit(1) to generate a sequence of random bits, determine if the number and length of identical bits runs match what is expected. By default, run_cnt is to test the next 65536 random values. This tests the a55 generator. randmprime.cal randmprime(bits, seed [,dbg]) Find a prime of the form h*2^n-1 >= 2^bits for some given x. The initial search points for 'h' and 'n' are selected by a cryptographic pseudo-random number generator. The optional argument, dbg, if set to 1, 2 or 3 turn on various debugging print statements. randombitrun.cal randombitrun([run_cnt]) Using randombit(1) to generate a sequence of random bits, determine if the number and length of identical bits runs match what is expected. By default, run_cnt is to test the next 65536 random values. This tests the Blum-Blum-Shub generator. randomrun.cal randomrun([run_cnt]) Perform the "G. Run test" (pp. 65-68) as found in Knuth's "Art of Computer Programming - 2nd edition", Volume 2, Section 3.3.2 on the builtin rand() function. This function will generate run_cnt 64 bit values. By default, run_cnt is to test the next 65536 random values. This tests the Blum-Blum-Shub generator. randrun.cal randrun([run_cnt]) Perform the "G. Run test" (pp. 65-68) as found in Knuth's "Art of Computer Programming - 2nd edition", Volume 2, Section 3.3.2 on the builtin rand() function. This function will generate run_cnt 64 bit values. By default, run_cnt is to test the next 65536 random values. This tests the a55 generator. repeat.cal repeat(digit_set, repeat_count) Return the value of the digit_set repeated repeat_count times. Both digit_set and repeat_count must be integers > 0. For example repeat(423,5) returns the value 423423423423423, which is the digit_set 423 repeated 5 times. regress.cal Test the correct execution of the calculator by reading this resource file. Errors are reported with '****' messages, or worse. :-) screen.cal up CUU /* same as up */ down = CUD CUD /* same as down */ forward CUF /* same as forward */ back = CUB CUB /* same as back */ save SCP /* same as save */ restore RCP /* same as restore */ cls home eraseline off bold faint italic blink rapidblink reverse concealed /* Lowercase indicates foreground, uppercase background */ black red green yellow blue magenta cyan white Black Red Green Yellow Blue Magenta Cyan White Define ANSI control sequences providing (i.e., cursor movement, changing foreground or background color, etc.) for VT100 terminals and terminal window emulators (i.e., xterm, Apple OS/X Terminal, etc.) that support them. For example: read screen print green:"This is green. ":red:"This is red.":black seedrandom.cal seedrandom(seed1, seed2, bitsize [,trials]) Given: seed1 - a large random value (at least 10^20 and perhaps < 10^93) seed2 - a large random value (at least 10^20 and perhaps < 10^93) size - min Blum modulus as a power of 2 (at least 100, perhaps > 1024) trials - number of ptest() trials (default 25) (optional arg) Returns: the previous random state Seed the cryptographically strong Blum generator. This functions allows one to use the raw srandom() without the burden of finding appropriate Blum primes for the modulus. set8700.cal set8700_getA1() defined set8700_getA2() defined set8700_getvar() defined set8700_f(set8700_x) defined set8700_g(set8700_x) defined Declare globals and define functions needed by dotest() (see dotest.cal) to evaluate set8700.line a line at a time. set8700.line A line-by-line evaluation file for dotest() (see dotest.cal). The set8700.cal file (and dotest.cal) should be read first. solve.cal solve(low, high, epsilon) Solve the equation f(x) = 0 to within the desired error value for x. The function 'f' must be defined outside of this routine, and the low and high values are guesses which must produce values with opposite signs. sumsq.cal ss(p) Determine the unique two positive integers whose squares sum to the specified prime. This is always possible for all primes of the form 4N+1, and always impossible for primes of the form 4N-1. sumtimes.cal timematsum(N) timelistsum(N) timematsort(N) timelistsort(N) timematreverse(N) timelistreverse(N) timematssq(N) timelistssq(N) timehmean(N,M) doalltimes(N) Give the user CPU time for various ways of evaluating sums, sums of squares, etc, for large lists and matrices. N is the size of the list or matrix to use. The doalltimes() function will run all fo the sumtimes tests. For example: doalltimes(1e6); surd.cal surd(a, b) surd_print(a) surd_conj(a) surd_norm(a) surd_value(a, xepsilon) surd_add(a, b) surd_sub(a, b) surd_inc(a) surd_dec(a) surd_neg(a) surd_mul(a, b) surd_square(a) surd_scale(a, b) surd_shift(a, b) surd_div(a, b) surd_inv(a) surd_sgn(a) surd_cmp(a, b) surd_rel(a, b) Calculate using quadratic surds of the form: a + b * sqrt(D). test1700.cal value This resource files is used by regress.cal to test the read and use keywords. test2600.cal global defaultverbose global err testismult(str, n, verbose) testsqrt(str, n, eps, verbose) testexp(str, n, eps, verbose) testln(str, n, eps, verbose) testpower(str, n, b, eps, verbose) testgcd(str, n, verbose) cpow(x, n, eps) cexp(x, eps) cln(x, eps) mkreal() mkcomplex() mkbigreal() mksmallreal() testappr(str, n, verbose) checkappr(x, y, z, verbose) checkresult(x, y, z, a) test2600(verbose, tnum) This resource files is used by regress.cal to test some of builtin functions in terms of accuracy and roundoff. test2700.cal global defaultverbose mknonnegreal() mkposreal() mkreal_2700() mknonzeroreal() mkposfrac() mkfrac() mksquarereal() mknonsquarereal() mkcomplex_2700() testcsqrt(str, n, verbose) checksqrt(x, y, z, v) checkavrem(A, B, X, eps) checkrounding(s, n, t, u, z) iscomsq(x) test2700(verbose, tnum) This resource files is used by regress.cal to test sqrt() for real and complex values. test3100.cal obj res global md res_test(a) res_sub(a, b) res_mul(a, b) res_neg(a) res_inv(a) res(x) This resource file is used by regress.cal to test determinants of a matrix test3300.cal global defaultverbose global err testi(str, n, N, verbose) testr(str, n, N, verbose) test3300(verbose, tnum) This resource file is used by regress.cal to provide for more determinant tests. test3400.cal global defaultverbose global err test1(str, n, eps, verbose) test2(str, n, eps, verbose) test3(str, n, eps, verbose) test4(str, n, eps, verbose) test5(str, n, eps, verbose) test6(str, n, eps, verbose) test3400(verbose, tnum) This resource file is used by regress.cal to test trig functions. containing objects. test3500.cal global defaultverbose global err testfrem(x, y, verbose) testgcdrem(x, y, verbose) testf(str, n, verbose) testg(str, n, verbose) testh(str, n, N, verbose) test3500(verbose, n, N) This resource file is used by regress.cal to test the functions frem, fcnt, gcdrem. test4000.cal global defaultverbose global err global BASEB global BASE global COUNT global SKIP global RESIDUE global MODULUS global K1 global H1 global K2 global H2 global K3 global H3 plen(N) defined rlen(N) defined clen(N) defined ptimes(str, N, n, count, skip, verbose) defined ctimes(str, N, n, count, skip, verbose) defined crtimes(str, a, b, n, count, skip, verbose) defined ntimes(str, N, n, count, skip, residue, mod, verbose) defined testnextcand(str, N, n, cnt, skip, res, mod, verbose) defined testnext1(x, y, count, skip, residue, modulus) defined testprevcand(str, N, n, cnt, skip, res, mod, verbose) defined testprev1(x, y, count, skip, residue, modulus) defined test4000(verbose, tnum) defined This resource file is used by regress.cal to test ptest, nextcand and prevcand builtins. test4100.cal global defaultverbose global err global K1 global K2 global BASEB global BASE rlen_4100(N) defined olen(N) defined test1(x, y, m, k, z1, z2) defined testall(str, n, N, M, verbose) defined times(str, N, n, verbose) defined powtimes(str, N1, N2, n, verbose) defined inittimes(str, N, n, verbose) defined test4100(verbose, tnum) defined This resource file is used by regress.cal to test REDC operations. test4600.cal stest(str [, verbose]) defined ttest([m, [n [,verbose]]]) defined sprint(x) defined findline(f,s) defined findlineold(f,s) defined test4600(verbose, tnum) defined This resource file is used by regress.cal to test searching in files. test5100.cal global a5100 global b5100 test5100(x) defined This resource file is used by regress.cal to test the new code generator declaration scope and order. test5200.cal global a5200 static a5200 f5200(x) defined g5200(x) defined h5200(x) defined This resource file is used by regress.cal to test the fix of a global/static bug. test8400.cal test8400() defined This resource file is used by regress.cal to check for quit-based memory leaks. test8500.cal global err_8500 global L_8500 global ver_8500 global old_seed_8500 global cfg_8500 onetest_8500(a,b,rnd) defined divmod_8500(N, M1, M2, testnum) defined This resource file is used by regress.cal to the // and % operators. test8600.cal global min_8600 global max_8600 global hash_8600 global hmean_8600 This resource file is used by regress.cal to test a change of allowing up to 1024 args to be passed to a builtin function. unitfrac.cal unitfrac(x) Represent a fraction as sum of distinct unit fractions. varargs.cal sc(a, b, ...) Example program to use 'varargs'. Program to sum the cubes of all the specified numbers. xx_print.cal is_octet(a) defined list_print(a) defined mat_print (a) defined octet_print(a) defined blk_print(a) defined nblk_print (a) defined strchar(a) defined file_print(a) defined error_print(a) defined Demo for the xx_print object routines. ## Copyright (C) 2000 David I. Bell and Landon Curt Noll ## ## Primary author: 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: README,v 30.2 2010/09/02 06:01:39 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $ ## ## Under source code control: 1990/02/15 01:50:32 ## File existed as early as: before 1990 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ NAME frac - return the fractional part of a number or of numbers in a value SYNOPSIS frac(x) TYPES If x is an object of type xx, frac(x) requires xx_frac to have been defined; other conditions on x and the value returned depend on the definition of xx_frac. For other x: x number (real or complex), matrix return number or matrix DESCRIPTION If x is an integer, frac(x) returns zero. For other real values of x, frac(x) returns the real number f for which x = i + f, where i is an integer, sgn(f) = sgn(x), and abs(f) < 1. If x is complex, frac(x) returns frac(re(x)) + frac(im(x))*1i. If x is a matrix, frac(x) returns the matrix m with the same structure as x in which m[[i]] = frac(x[[i]]). EXAMPLE ; c = config("mode", "frac") ; print frac(3), frac(22/7), frac(27/7), frac(-3.125), frac(2.15 - 3.25i) 0 1/7 6/7 -1/8 3/20-1i/4 LIMITS none LINK LIBRARY NUMBER *qfrac(NUMBER *x) COMPLEX *c_frac(COMPLEX *x) MATRIX *matfrac(MATRIX *x) SEE ALSO int, ceil, floor ## 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: frac,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/frac,v $ ## ## Under source code control: 1995/12/18 03:30:59 ## 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 fsize - return the file size SYNOPSIS fsize(fd) TYPES fd file return int DESCRIPTION This function returns the number of bytes in a file. When at the end of file, ftell returns a value which is 1 greater than the file size as reported by fsize. EXAMPLE ; fd = fopen("/etc/motd", "r") ; fsize(fd) 784 LIMITS fd must be associated with an open file LINK LIBRARY none SEE ALSO errno, fclose, feof, ferror, fflush, fgetc, fgetline, fgets, files, fopen, fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt ## 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: fsize,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fsize,v $ ## ## Under source code control: 1995/03/04 11:33:20 ## 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 fputs - write a string to a file SYNOPSIS fputs(fd, s1, s2, ...) TYPES fd file stream open for writing s1, s2, ... strings return null value DESCRIPTION This function writes in succession the strings s1, s2, ..., to the file associated with fd. EXAMPLE ; fd = fopen("/tmp/newfile", "w") ; fputs(fd, "chongo was", " here\n") ; fd2 = fopen("/tmp/newfile", "r") ; fgetline(fd2) "chongo was here" LIMITS The number of arguments is not to exceed 1024 LINK LIBRARY none SEE ALSO errno, fclose, feof, ferror, fflush, fgetc, fgetfile, fgetline, fgets, files, fopen, fprintf, fputc, fseek, fsize, ftell, isfile ## 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: fputs,v 30.1 2007/03/16 11:10:42 chongo Exp $ ## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fputs,v $ ## ## Under source code control: 1995/03/04 11:33:20 ## File existed as early as: 1995 ## ## chongo /\oo/\ http://www.isthe.com/chongo/ ## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/ Calc Enhancement Wish List: Send calc comments, suggestions, bug fixes, enhancements and interesting calc scripts that you would like you see included in future distributions to: calc-contrib at asthe dot com The following items are in the calc wish list. Programs like this can be extended and improved forever. Calc bug reports, however, should be sent to: calc-bugs at asthe dot com [[ NOTE: Replace 'at' with @, 'dot' is with . and remove the spaces ]] [[ NOTE: The EMail address uses 'asthe' and the web site URL uses 'isthe' ]] See the 'todo' help file for higher priority todo items. =-= * In general use faster algorithms for large numbers when they become known. In particular, look at better algorithms for very large numbers -- multiply, square and mod in particular. * Implement an autoload feature. Associate a calc resource filename with a function or global variable. On the first reference of such item, perform an automatic load of that file. * Add error handling statements, so that QUITs, errors from the 'eval' function, division by zeroes, and so on can be caught. This should be done using syntax similar to: ONERROR statement DO statement; Something like signal isn't versatile enough. * Add a debugging capability so that functions can be single stepped, breakpoints inserted, variables displayed, and so on. * Figure out how to write all variables out to a file, including deeply nested arrays, lists, and objects. Add the ability to read and write a value in some binary form. Clearly this is easy for non-neg integers. The question of everything else is worth pondering. * Eliminate the need for the define keyword by doing smarter parsing. * Allow results of a command (or all commands) to be re-directed to a file or piped into a command. * Add some kind of #include and #define facility. Perhaps use the C pre-processor itself? * Support a more general input and output base mode other than just dec, hex or octal. * Implement a form of symbolic algebra. Work on this has already begun. This will use backquotes to define expressions, and new functions will be able to act on expressions. For example: x = `hello * strlen(mom)`; x = sub(x, `hello`, `hello + 1`); x = sub(x, `hello`, 10, `mom`, "curds"); eval(x); prints 55. * Place the results of previous commands into a parallel history list. Add a binding that returns the saved result of the command so that one does not need to re-execute a previous command simply to obtain its value. If you have a command that takes a very long time to execute, it would be nice if you could get at its result without having to spend the time to reexecute it. * Add a binding to delete a value from the history list. One may need to remove a large value from the history list if it is very large. Deleting the value would replace the history entry with a null value. * Add a binding to delete a command from the history list. Since you can delete values, you might as well be able to delete commands. * All one to alter the size of the history list thru config(). In some cases, 256 values is too small, in others it is too large. * Add a builtin that returns a value from the history list. As an example: histval(-10) returns the 10th value on the history value list, if such a value is in the history list (null otherwise). And: histval(23) return the value of the 23rd command given to calc, if such a value is in the history list (null otherwise). It would be very helpful to use the history values in subsequent equations. * Add a builtin that returns command as a string from the history list. As an example: history(-10) returns a string containing the 10th command on the history list, if a such a value is in the history list (empty string otherwise). And: history(23) return the string containing the 23rd command given to calc, if such a value is in the history list (empty string otherwise). One could use the eval() function to re-evaluate the command. * Allow one to optionally restore the command number to calc prompts. When going back in the history list, indicate the command number that is being examined. The command number was a useful item. When one is scanning the history list, knowing where you are is hard without it. It can get confusing when the history list wraps or when you use search bindings. Command numbers would be useful in conjunction with positive args for the history() and histval() functions as suggested above. * Add a builtin that returns the current command number. For example: cmdnum() returns the current command number. This would allow one to tag a value in the history list. One could save the result of cmdnum() in a variable and later use it as an arg to the histval() or history() functions. * Add a factoring builtin functions. Provide functions that perform multiple polynomial quadratic sieves, elliptic curve, difference of two squares, N-1 factoring as so on. Provide a easy general factoring builtin (say factor(foo)) that would attempt to apply whatever process was needed based on the value. Factoring builtins would return a matrix of factors. It would be handy to configure, via config(), the maximum time that one should try to factor a number. By default the time should be infinite. If one set the time limit to a finite value and the time limit was exceeded, the factoring builtin would return whatever if had found thus far, even if no new factors had been found. Another factoring configuration interface, via config(), that is needed would be to direct the factoring builtins to return as soon as a factor was found. * Allow one to config calc break up long output lines. The command: calc '2^100000' will produce one very long line. Many times this is reasonable. Long output lines are a problem for some utilities. It would be nice if one could configure, via config(), calc to fold long lines. By default, calc should continue to produce long lines. One option to config should be to specify the length to fold output. Another option should be to append a trailing \ on folded lines (as some symbolic packages use). * Allow one to use the READ and WRITE commands inside a function. * Remove or increase limits on factor(), lfactor(), isprime(), nextprime(), and prevprime(). Currently these functions cannot search for factors > 2^32. * Add read -once -try "filen