[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] rcalc 2.0 (Ruby Calculator

Josef 'Jupp' Schugt

9/5/2003 9:10:00 PM

Saluton!

I am proud to announce version 2.0 of Ruby Calculator (rcalc for
short). Ruby calculator is a scientific RPN (Reverse Polish Notation)
calculator based on the extmath library. At present it only provides
a commandline interface but that may change in the future. Supported
functions are:

!, !=, #, *, **, +, -, ., /, <, <=, ==, >, >=, ?, ^, abs, acos,
acosh, acot, acoth, acsc, acsch, add, and, asec, asech, asin,
asinh, atan, atan2, atanh, beta, c, ceil, cos, cosh, cot, coth,
csc, csch, delta, div, drop, dup, e, epsilon, eq, eqv, erf, erfc,
exp, exp10, exp2, f, factorial, false, floor, frexp, gcd, ge, gt,
hypot, in, inv, lcm, ld, ldexp, le, lg, lgamma, linsolve, ln, log,
log10, log2, lt, mul, nand, ne, neqv, nor, not, or, over, p, pi,
pow, puts, read, rnd, root, rot, round, sec, sech, sign, sin, sinc,
sinh, sqr, sqrt, sqsolve, sub, swap, t, tan, tanh, tgamma, to_f,
to_i, to_s, true, x, xor

You want to input mass in kg and speed in m/s and need kinetic energy
in J? That's a one-liner:

rcalc 'mass [kg]?' in 0.5 x 'speed [m/s]?' in sqr x 'E_kin [J]' p

The interaction looks like this:

mass [kg]?
7
speed [m/s]?
3
E_kin [J]
31.5

Wonder why 'x' is used for multiplication? This is because of Unix
shells that interpret '*' as all files and subdirectories in the
current directory and '.' as the present directory. On systems that
don't do that (or if you escape these characters) they also result in
multiplication and so does 'mul'.

rcalc is self-documenting which means that you can ask for help on
specific functions. If alternative names of a function are supported
they are listed - try 'rcalc --help' or 'rcalc -h' for details.

rcalc's homepage is at

http://rcalc.ruby...

Note that rcalc requires extmath. extmath's homepage is at

http://extmath.ruby...

Presently only radian is supported but support for degree and gon is
the next issue I will address.

Gis,

Josef 'Jupp' Schugt

11 Answers

mgarriss

9/6/2003 6:19:00 AM

0

Wow, good work. That''s really cool. I''ll be trying it out soon. :)

Michael


Josef 'Jupp' Schugt

9/9/2003 9:43:00 PM

0

Saluton!

* Josef ''Jupp'' Schugt; 2003-09-05, 19:41 UTC:
> rcalc''s homepage is at
>
> http://rcalc.ruby...
>
> Note that rcalc requires extmath. extmath''s homepage is at
>
> http://extmath.ruby...

Still holds.

> Presently only radian is supported but support for degree and gon is
> the next issue I will address.

Done.

Gis,

Josef ''Jupp'' Schugt
--
Scientific RPN calculator (in Ruby) http://rcalc.ruby...


Harry Ohlsen

9/10/2003 12:44:00 AM

0

Josef ''Jupp'' Schugt wrote:

> Saluton!
>
> * Josef ''Jupp'' Schugt; 2003-09-05, 19:41 UTC:
>
>>rcalc''s homepage is at
>>
>> http://rcalc.ruby...

Have you or anyone else written a command-line front-end for the Engine? It would be great to have as a more capable equivalent of Unix''s "dc", particularly given that it would run on Windows, too.

Harry O.





Josef 'Jupp' Schugt

9/10/2003 7:38:00 PM

0

Saluton!

* Harry Ohlsen; 2003-09-10, 11:57 UTC:
> Have you or anyone else written a command-line front-end for the
> Engine?

I am a bit unsure what you are looking for but I will add an
interactive mode that allows you to directly enter commands - instead
of providing them as command line parameters.

Now that there is an explicit request for this I will add this first
and delay adding support for math-const library.

Gis,

Josef ''Jupp'' Schugt
--
Scientific RPN calculator (in Ruby) http://rcalc.ruby...

Josef 'Jupp' Schugt

9/10/2003 10:49:00 PM

0

Saluton!

* Harry Ohlsen; 2003-09-10, 11:57 UTC:
> Have you or anyone else written a command-line front-end for the
> Engine?

You are invited to give version 2.2 a try. Follows output of
''rcalc --help'':

-------------------------------------------------------------------------------
AVAILABLE FUNCTIONS: !, !=, #, *, **, +, -, ., /, <, <=, ==, >, >=, ?, ^, abs,
acos, acosh, acot, acoth, acsc, acsch, add, and, asec, asech, asin, asinh,
atan, atan2, atanh, beta, c, ceil, cos, cosh, cot, coth, csc, csch, deg,
deg2gon, deg2rad, delta, div, drop, dup, e, epsilon, eq, eqv, erf, erfc, exp,
exp10, exp2, f, factorial, false, floor, frexp, gcd, ge, gon, gon2deg, gon2rad,
gt, hypot, in, inv, lcm, ld, ldexp, le, lg, lgamma, linsolve, ln, log, log10,
log2, lt, mul, nand, ne, neqv, nor, not, or, over, p, pi, pow, puts, rad,
rad2deg, rad2gon, read, rnd, root, rot, round, sec, sech, sign, sin, sinc,
sinh, sqr, sqrt, sqsolve, sub, swap, t, tan, tanh, tgamma, to_f, to_i, to_s,
true, x, xor
-------------------------------------------------------------------------------
General help: ''rcalc -h'' or ''rcalc --help''
Specific function(s): ''rcalc -h <fn> ... '' or ''rcalc --help <fn> ...''
HTML help: ''rcalc -H'' or ''rcalc --htmlhelp''
Run scripts: ''rcalc -f <file> ...'' or ''rcalc --file <file> ...''
Interative usage: ''rcalc'' (without any arguments)
-------------------------------------------------------------------------------
Depending on your OS it may be necessary to escape some of the operators.
In interactive mode ''[<fn> ...] h[elp]'' displays help for the functions
preceeding the h[elp] command on the same input line.
To exit interactive mode use EOF (Ctrl-D), ''q'', or ''quit''.
-------------------------------------------------------------------------------

Have fun,

Josef ''Jupp'' Schugt
--
Scientific RPN calculator (in Ruby) http://rcalc.ruby...

Harry Ohlsen

9/10/2003 11:40:00 PM

0

Josef ''Jupp'' Schugt wrote:

> Saluton!
>
> * Harry Ohlsen; 2003-09-10, 11:57 UTC:
>
>>Have you or anyone else written a command-line front-end for the
>>Engine?
>
> You are invited to give version 2.2 a try. Follows output of
> ''rcalc --help'':

Great! I''ll give it a try.

That was an incredibly quick turn around only one "sleep" for me :-).

Cheers,

Harry O.



Harry Ohlsen

9/11/2003 12:16:00 AM

0

> You are invited to give version 2.2 a try. Follows output of
> ''rcalc --help'':

This is great!

My only suggestion would be that it would be nice if one could enter multiple commands on one line.

Ie, rather than just trying to execute the line as typed, you could split it into separate words using something like:

commands.split(/[\s;,]+/).each do |cmd|
# execute cmd
end

I''ve specified whitespace, commas and semicolons as potential command separators, simply because people are likely to guess one of them.

Just a thought.

Again, great work.

Cheers,

Harry O.



ejb

9/11/2003 5:07:00 PM

0

I tried installing this with the usual:
ruby install.rb config
ruby install.rb setup
ruby install.rb install

I''m on a Windows XP Pro system.
I tried running the install commands under a cygwin shell and a ''cmd'' shell.
No Joy.
Any suggestions?

----------------------- here''s my config.save file::::
bin-dir=$prefix/bin
site-ruby=$prefix/lib/ruby/site_ruby/1.8
prefix=c:/ruby
ruby-path=c:/ruby/bin/ruby
make-prog=make
rb-dir=$site-ruby
without-ext=no
ruby-prog=c:/ruby/bin/ruby
site-ruby-common=$prefix/lib/ruby/site_ruby
std-ruby=$prefix/lib/ruby/1.8
data-dir=$prefix/share
so-dir=$prefix/lib/ruby/site_ruby/1.8/i386-msvcrt



"Josef ''Jupp'' Schugt" <jupp@gmx.de> wrote in message news:<20030910202238.GB1861@jupp%gmx.de>...
> Saluton!
>
> * Harry Ohlsen; 2003-09-10, 11:57 UTC:
> > Have you or anyone else written a command-line front-end for the
> > Engine?
>
> You are invited to give version 2.2 a try. Follows output of
> ''rcalc --help'':
>
> -------------------------------------------------------------------------------
> AVAILABLE FUNCTIONS: !, !=, #, *, **, +, -, ., /, <, <=, ==, >, >=, ?, ^, abs,
> acos, acosh, acot, acoth, acsc, acsch, add, and, asec, asech, asin, asinh,
> atan, atan2, atanh, beta, c, ceil, cos, cosh, cot, coth, csc, csch, deg,
> deg2gon, deg2rad, delta, div, drop, dup, e, epsilon, eq, eqv, erf, erfc, exp,
> exp10, exp2, f, factorial, false, floor, frexp, gcd, ge, gon, gon2deg, gon2rad,
> gt, hypot, in, inv, lcm, ld, ldexp, le, lg, lgamma, linsolve, ln, log, log10,
> log2, lt, mul, nand, ne, neqv, nor, not, or, over, p, pi, pow, puts, rad,
> rad2deg, rad2gon, read, rnd, root, rot, round, sec, sech, sign, sin, sinc,
> sinh, sqr, sqrt, sqsolve, sub, swap, t, tan, tanh, tgamma, to_f, to_i, to_s,
> true, x, xor
> -------------------------------------------------------------------------------
> General help: ''rcalc -h'' or ''rcalc --help''
> Specific function(s): ''rcalc -h <fn> ... '' or ''rcalc --help <fn> ...''
> HTML help: ''rcalc -H'' or ''rcalc --htmlhelp''
> Run scripts: ''rcalc -f <file> ...'' or ''rcalc --file <file> ...''
> Interative usage: ''rcalc'' (without any arguments)
> -------------------------------------------------------------------------------
> Depending on your OS it may be necessary to escape some of the operators.
> In interactive mode ''[<fn> ...] h[elp]'' displays help for the functions
> preceeding the h[elp] command on the same input line.
> To exit interactive mode use EOF (Ctrl-D), ''q'', or ''quit''.
> -------------------------------------------------------------------------------
>
> Have fun,
>
> Josef ''Jupp'' Schugt

Josef 'Jupp' Schugt

9/11/2003 8:41:00 PM

0

Saluton!

* Harry Ohlsen; 2003-09-11, 12:01 UTC:
> I''ve specified whitespace, commas and semicolons as potential
> command separators, simply because people are likely to guess one
> of them.

Before asking for features please make sure that they are not already
present :-> I forgot to mention that you can enter several commands
on one line as long as they are separated by white space.

I don''t want to support the use of a comma to avoid confusion. Most
people would read ''3,142'' as ''three thousand one hundred fourty-two''
or as ''drei komma eins vier zwei''. The latter is the German version
which in English means ''three dot one four two''. Few people would
read it as ''three followed by hundred fourty-two''.

As far as the use of semicolon is concerned: I want to use it as a
comment character (as it is in LISP).

BTW: I found a bug in interactive and script mode that is related to
splitting lines - strings in quotation signs are split, too. I will
look into that.

Gis,

Josef ''Jupp'' Schugt
--
Scientific RPN calculator (in Ruby) http://rcalc.ruby...

Josef 'Jupp' Schugt

9/12/2003 12:11:00 PM

0

Saluton!

* Ed Baker; 2003-09-11, 20:51 UTC:
> I''m on a Windows XP Pro system.
> I tried running the install commands under a cygwin shell and a
> ''cmd'' shell.
> No Joy.
> Any suggestions?

I cannot help you because I don''t run Windows. If you find a solution
please send it to me so that I can add the information to the INSTALL
instructions.

Gis,

Josef ''Jupp'' Schugt
--
Scientific RPN calculator (in Ruby) http://rcalc.ruby...