emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Evaluating simple inline expressions in org-mode


From: Eric S Fraga
Subject: Re: [O] Evaluating simple inline expressions in org-mode
Date: Mon, 8 Feb 2016 09:33:03 +0000

On Sunday,  7 Feb 2016 at 16:45, H. Dieter Wilhelm wrote:
>>>> works as well.  I'm not sure how you define variables in calc however...
>>>
>
>>> You could write something like src_calc[:var x=3.41]{2*x} :-)
>>
>> Yes but can you save a variable for use in a later expression?
>
> Well, at the moment I don't know another way as defining the calc
> variables on the lisp level:
>
> #+BEGIN_SRC emacs-lisp
> (setq var-foo 9.81
>       var-x 3.14
>       var-bar ...)
> #+END_SRC
>
> Note: `var-' is a special prefix for the calc variables `foo', `x',

Thanks for this.  Very useful to know.  Using this, I've created a macro
which will be quite useful for me in preparing some lecture notes with
simple calculations for illustration:

#+begin_src org
  ,#+macro: calculate $2 \leftarrow src_calc[:exports code]{$1} = 
src_emacs-lisp{(setq var-$2 (string-to-number (calc-eval "evalv($1)")))}

  An example:

  {{{calculate(x+y,z)}}}
#+end_src

-- 
: Eric S Fraga (0xFFFCF67D), Emacs 25.0.90.1, Org release_8.3.3-535-g7213aa



reply via email to

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