unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Marco Parrone <marc0@autistici.org>
Subject: Re: Evaluation of "standard" style math expresssions.
Date: Tue, 21 Sep 2004 12:07:56 GMT	[thread overview]
Message-ID: <87vfe7u8sw.fsf@autistici.org> (raw)
In-Reply-To: 20040921114408.GA2296@matijek.plusseven.com

Alex Polite on 21 Sep 2004 11:48:13 GMT writes:

> I know how to evaluate mathematical expressions expressed in lisp in
> any emacs buffer.  (eg (+ 17 42))
>
> But I'd like to be able to eval expression where the notation is the
> kind you learn in school (eg (17 + 42))
>
> How do I do it?

you can pipe the expression to bc.

for example on a line you have

1 + 2 * 3

you can set the mark `C-SPC' at the beginning of the line, then move
the point in the next line `C-n', then pipe the line to bc `M-| bc RET'

try with

9 / 2

you get 4, you may want to do this instead

scale=1
9 / 2

(set the mark at the beginning of the first line and move the point
after the second), so to get `4.5'.

for more informations about bc syntax, do `M-x man RET bc RET'.

-- 
Marco Parrone <marc0@autistici.org>
fingerprint: F7D4 527B DE97 4090 657B  6E4E 8B63 1167 (4507 0AD6)

  parent reply	other threads:[~2004-09-21 12:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-21 11:48 Evaluation of "standard" style math expresssions Alex Polite
2004-09-21 11:53 ` Joakim Hove
2004-09-21 12:07 ` Marco Parrone [this message]
2004-09-21 12:31   ` Alex Polite
2004-09-21 12:10 ` Albert Reiner
2004-09-21 15:29   ` Stefan Monnier
2004-09-21 15:35     ` Jay Belanger
2004-09-21 17:50     ` Albert Reiner
2004-09-21 20:22       ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vfe7u8sw.fsf@autistici.org \
    --to=marc0@autistici.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).