From: Nikos Apostolakis <nikos.ap@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Using calc's translations programaticaly
Date: Mon, 22 Oct 2007 13:32:51 -0400 [thread overview]
Message-ID: <861wbnm4vw.fsf@knotter.bcc.cuny.edu> (raw)
In-Reply-To: m3prz76lkr.fsf@gmail.com
Jay Belanger <jay.p.belanger@gmail.com> writes:
>> Calc has this great feature that automatically (and pretty
>> accurately) translates formulas written in one language to an other
>> language. For example if I have a LaTeX formula that I want to pass
>> to maxima (say) I can simply do "C-x * e d W C-x * e" and voila: the
>> formula is transformed to a form that maxima understands.
>
> Well, that's supposed to transform it to Maple, but perhaps that's
> close enough.
Pretty close. I've been thinking of defining a new calc language
for maxima for some time now, but the Maple language works for most
of my needs with little modification that I've never have come
around to do it.
>
>> My question is how can I access this feature from elisp?
>
> Calc really isn't set up to do that, but perhaps something like
>
> (defun calc-change-lang (expr old-lang new-lang)
> (require 'calc-lang)
> (let (math-expr-opers
> math-expr-function-mapping
> math-expr-special-function-mapping
> math-expr-variable-mapping
> calc-language-input-filter
> calc-language-output-filter
> calc-vector-brackets
> calc-complex-format
> calc-radix-formatter
> calc-function-open
> calc-function-close
> calc-language
> calc-language-option)
> (calc-set-language old-lang)
> (let ((expr (math-read-expr expr)))
> (calc-set-language new-lang)
> (math-format-value expr))))
>
> would work (the first `let' is to prevent the current language from
> being disturbed).
This seems to work great! Thanks a lot.
>The interesting (for this) values of old-lang and
> new-lang might be:
> nil (normal Calc language)
> 'c
> 'pascal
> 'fortran
> 'tex
> 'latex
> 'eqn
> 'math (Mathematica)
> 'maple
'big is also interesting. It's helpfull for writing ascii-art
formulas for posts, emails etc. For example:
____________
| 2
(-b) +/- \| b - 4 a c
-----------------------
2 a
Thanks again,
Nikos
>
> Jay
next prev parent reply other threads:[~2007-10-22 17:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.2400.1192989832.18990.help-gnu-emacs@gnu.org>
2007-10-22 18:39 ` Using calc's translations programaticaly Jay Belanger
2007-10-22 17:32 ` Nikos Apostolakis [this message]
2007-10-21 12:43 Nikos Apostolakis
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=861wbnm4vw.fsf@knotter.bcc.cuny.edu \
--to=nikos.ap@gmail.com \
--cc=help-gnu-emacs@gnu.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).