From: Janis Papanagnou on 28 Nov 2006 13:51
Kenny McCormack wrote:
> In article <1164732572.222070.82070(a)j44g2000cwa.googlegroups.com>,
> Janis <janis_papanagnou(a)hotmail.com> wrote:
>>My first reply to your "my favorite calculator" statement might
>>have been too brief to understand why it is a problem to rely
>>on non-standard tools. You seem to assume that on whatever
>>machine you want you may install whatever tool you like. Real
>>Life is different.
> Maybe you need to trade your life in on new and better one.
In Europe, where I live, even sysadmins seem nowadays not to be
allowed to do what they like on their company's machines. I've
heard similar things from the US of America. It may be different
where you live and work.
> Seriously - if you *can't* install your own tools, then you're living in
> a box.
"can not" != "may not".
On _my own_ boxes I can do anything I like, but that was not the
From: Janis Papanagnou on 28 Nov 2006 14:24
Loki Harfagr wrote:
Thank's for the link, Loki. Occasionally I had looked for a free tool
that does symbolic algebra, but never stumbled across this one. I'll
have a closer look... 8-)
Compiles and works nicely, just missing functions - but I haven't yet
looked into the docs (I'm sure there are functions).
> But this is not much on topic for 'c.u.shell' so I rest my case ;-)
But made this thread worth reading (for me)! ;-) Thank's again.
From: Chris F.A. Johnson on 28 Nov 2006 18:16
On 2006-11-27, William Park wrote:
> dave <daf(a)a64.comcast.net> wrote:
>> Does anyone have any comments on bc vs calc (my favorite calculator
> Yes, I didn't write either of them.
I *did* write calc; it's a shell function. I think I've posted it
here before (and it is in my book). It's probably not the calc that
Dave is referring to, but there are many programs with that name,
so it's impossible to say what he means.
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
From: Loki Harfagr on 29 Nov 2006 14:38
Le Tue, 28 Nov 2006 18:16:02 -0500, Chris F.A. Johnson a �crit�:
> On 2006-11-27, William Park wrote:
>> dave <daf(a)a64.comcast.net> wrote:
>>> Does anyone have any comments on bc vs calc (my favorite calculator
>> Yes, I didn't write either of them.
> I *did* write calc; it's a shell function. I think I've posted it
> here before (and it is in my book). It's probably not the calc that
> Dave is referring to, but there are many programs with that name,
> so it's impossible to say what he means.
Now that I think about this I also did write 'calc' though it was circa
1981 and an APL function I wrote to provide infinite precision calculus,
that was quite painful in performances as it ran in a 32 to 64 KB
"WorkSpace" on a PDP-10 running Tymshare, after browsing the link provided
by the OP I can certify hereby that it is *not* the same one ;D)
From: Kaz Kylheku on 30 Nov 2006 02:22
> Does anyone have any comments on bc vs calc (my favorite calculator
Just this: learn a real programming language. ANSI Common Lisp.
The CLISP implementation (clisp.cons.org) is good for interactive use,
including as a desktop calculator, if you wish.
Calc is a pale imitation that pales by comparison: evidence of
Greenspun's Tenth Rule of Programming hard at work.
This session touches on some diversity you can find:
First, a simple demonstration of the foreign function interface, by
means of which we gain access into the libc ABI to call the strerror
function. Much more complex things are possible. Then some numeric
computing with bignums, rationals and complex numbers.
In Lisp, the square root of -1 is properly a complex number. When two
rationals add to an integer, an integer type comes out.
Then we use the LOOP macro to extract error strings from libc, and make
them into a list, which we then filter using MAPCAR to upcase
everything, then reverse the strings instead.
Then we get bored and end the article. But not before showing how LOOP
is actually a macro written in Lisp which performs syntactic
transformation to do its job.
No time for the object system with multiple dispatch, auxiliary
methods, programmable method combinations, meta-object protocol. Nor
for the condition system, restarts, special variables, lexical
closures, vectors and structs, symbols, packages, the streams library,
gray streams, CLISP's character encoding library, read macros, FORMAT,
destructuring-bind, ... and on and on.
CLISP has a fast bignum library, it's very good for bignum
computations; better than natively compiling Lisp implementations, even
though it only compiles to byte code. It would be interesting to
benchmark CLISP and calc on the same problems.
Psst. Don't tell Janis.
0:localhost:~/lisp$ clisp -q
> (use-package :ffi)
> (def-call-out strerror (:language :stdc) (:library "libc.so.6")
(:arguments (errnum int)) (:return-type c-string))
> (strerror 13)
> (strerror 0)
> (strerror 22)
> (expt 19 56)
> (/ 123 57)
> (- (/ 123 57) 3/19)
> (sqrt -1)
> (sqrt -1.0)
> (cosh #c(-1 -1))
> (loop for x below 32 collecting (strerror x))
("Success" "Operation not permitted" "No such file or directory" "No
"Interrupted system call" "Input/output error" "No such device or
"Argument list too long" "Exec format error" "Bad file descriptor" "No
"Resource temporarily unavailable" "Cannot allocate memory"
"Permission denied" "Bad address"
"Block device required" "Device or resource busy" "File exists"
"Invalid cross-device link"
"No such device" "Not a directory" "Is a directory" "Invalid argument"
"Too many open files in system" "Too many open files" "Inappropriate
ioctl for device"
"Text file busy" "File too large" "No space left on device" "Illegal
"Read-only file system" "Too many links")
> (mapcar #'string-upcase (loop for x below 32 collecting (strerror
("SUCCESS" "OPERATION NOT PERMITTED" "NO SUCH FILE OR DIRECTORY" "NO
"INTERRUPTED SYSTEM CALL" "INPUT/OUTPUT ERROR" "NO SUCH DEVICE OR
"ARGUMENT LIST TOO LONG" "EXEC FORMAT ERROR" "BAD FILE DESCRIPTOR" "NO
"RESOURCE TEMPORARILY UNAVAILABLE" "CANNOT ALLOCATE MEMORY"
"PERMISSION DENIED" "BAD ADDRESS"
"BLOCK DEVICE REQUIRED" "DEVICE OR RESOURCE BUSY" "FILE EXISTS"
"INVALID CROSS-DEVICE LINK"
"NO SUCH DEVICE" "NOT A DIRECTORY" "IS A DIRECTORY" "INVALID ARGUMENT"
"TOO MANY OPEN FILES IN SYSTEM" "TOO MANY OPEN FILES" "INAPPROPRIATE
IOCTL FOR DEVICE"
"TEXT FILE BUSY" "FILE TOO LARGE" "NO SPACE LEFT ON DEVICE" "ILLEGAL
"READ-ONLY FILE SYSTEM" "TOO MANY LINKS")
> (mapcar #'reverse (loop for x below 32 collecting (strerror x)))
("sseccuS" "dettimrep ton noitarepO" "yrotcerid ro elif hcus oN"
"ssecorp hcus oN"
"llac metsys detpurretnI" "rorre tuptuo/tupnI" "sserdda ro ecived hcus
"gnol oot tsil tnemugrA" "rorre tamrof cexE" "rotpircsed elif daB"
"sessecorp dlihc oN"
"elbaliavanu yliraropmet ecruoseR" "yromem etacolla tonnaC" "deined
noissimreP" "sserdda daB"
"deriuqer ecived kcolB" "ysub ecruoser ro eciveD" "stsixe eliF" "knil
"ecived hcus oN" "yrotcerid a toN" "yrotcerid a sI" "tnemugra dilavnI"
"metsys ni selif nepo ynam ooT" "selif nepo ynam ooT" "ecived rof
"ysub elif txeT" "egral oot eliF" "ecived no tfel ecaps oN" "kees
"metsys elif ylno-daeR" "sknil ynam ooT")
> (macroexpand '(loop for x below 32 collecting (strerror x)))
(MACROLET ((LOOP-FINISH NIL (SYSTEM::LOOP-FINISH-ERROR)))
(LET ((X 0))
(LET ((#:ACCULIST-VAR-2970 NIL))
(MACROLET ((LOOP-FINISH NIL '(GO SYSTEM::END-LOOP)))
(TAGBODY SYSTEM::BEGIN-LOOP (WHEN (>= X 32) (LOOP-FINISH))
(PROGN (SETQ #:ACCULIST-VAR-2970 (CONS (STRERROR X)
(PSETQ X (+ X 1)) (GO SYSTEM::BEGIN-LOOP) SYSTEM::END-LOOP
(MACROLET ((LOOP-FINISH NIL (SYSTEM::LOOP-FINISH-WARN) '(GO
(RETURN-FROM NIL (SYSTEM::LIST-NREVERSE