help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using calc's translations programaticaly


From: Jay Belanger
Subject: Re: Using calc's translations programaticaly
Date: Mon, 22 Oct 2007 13:39:00 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux)

> 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.

> 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).  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

Jay


reply via email to

[Prev in Thread] Current Thread [Next in Thread]