From: Janis Papanagnou on
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
point.

Janis
From: Janis Papanagnou on
Loki Harfagr wrote:
>
> http://mathomatic.orgserve.de/math/

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.

Janis
From: Chris F.A. Johnson on
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
>> program)?
>
> 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
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
>>> program)?
>>
>> 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
dave wrote:
> Does anyone have any comments on bc vs calc (my favorite calculator
> program)?

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
[1]> (use-package :ffi)
T
[2]> (def-call-out strerror (:language :stdc) (:library "libc.so.6")
(:arguments (errnum int)) (:return-type c-string))
STRERROR
[3]> (strerror 13)
"Permission denied"
[4]> (strerror 0)
"Success"
[5]> (strerror 22)
"Invalid argument"
[6]> (expt 19 56)
407569478172909828847318650548420153417875032325531352984650263038054881
[7]> (/ 123 57)
41/19
[8]> (- (/ 123 57) 3/19)
2
[9]> (sqrt -1)
#C(0 1)
[10]> (sqrt -1.0)
#C(0 1.0)
[11]> (cosh #c(-1 -1))
#C(0.83373004 0.9888977)
[12]> (loop for x below 32 collecting (strerror x))
("Success" "Operation not permitted" "No such file or directory" "No
such process"
"Interrupted system call" "Input/output error" "No such device or
address"
"Argument list too long" "Exec format error" "Bad file descriptor" "No
child processes"
"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
seek"
"Read-only file system" "Too many links")
[13]> (mapcar #'string-upcase (loop for x below 32 collecting (strerror
x)))
("SUCCESS" "OPERATION NOT PERMITTED" "NO SUCH FILE OR DIRECTORY" "NO
SUCH PROCESS"
"INTERRUPTED SYSTEM CALL" "INPUT/OUTPUT ERROR" "NO SUCH DEVICE OR
ADDRESS"
"ARGUMENT LIST TOO LONG" "EXEC FORMAT ERROR" "BAD FILE DESCRIPTOR" "NO
CHILD PROCESSES"
"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
SEEK"
"READ-ONLY FILE SYSTEM" "TOO MANY LINKS")
[14]> (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
oN"
"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-ssorc dilavnI"
"ecived hcus oN" "yrotcerid a toN" "yrotcerid a sI" "tnemugra dilavnI"
"metsys ni selif nepo ynam ooT" "selif nepo ynam ooT" "ecived rof
ltcoi etairporppanI"
"ysub elif txeT" "egral oot eliF" "ecived no tfel ecaps oN" "kees
lagellI"
"metsys elif ylno-daeR" "sknil ynam ooT")
[15]> (macroexpand '(loop for x below 32 collecting (strerror x)))
(MACROLET ((LOOP-FINISH NIL (SYSTEM::LOOP-FINISH-ERROR)))
(BLOCK NIL
(LET ((X 0))
(PROGN
(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)
#:ACCULIST-VAR-2970)))
(PSETQ X (+ X 1)) (GO SYSTEM::BEGIN-LOOP) SYSTEM::END-LOOP
(MACROLET ((LOOP-FINISH NIL (SYSTEM::LOOP-FINISH-WARN) '(GO
SYSTEM::END-LOOP)))
(RETURN-FROM NIL (SYSTEM::LIST-NREVERSE
#:ACCULIST-VAR-2970)))))))))) ;
T