[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [babel] inline call within table formula?
From: |
Eric Schulte |
Subject: |
Re: [O] [babel] inline call within table formula? |
Date: |
Sun, 10 Jul 2011 09:54:57 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Hi Eric,
The `sbe' macro can be used to evaluate code blocks in table formula.
For Example:
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 3.5 |
#+TBLFM: @7$1='(sbe mean (lst @address@hidden))
#+source: mean
#+begin_src emacs-lisp :var lst=()
(let ((num (car lst)) (nums (cdr lst)))
(/ (float (+ num (apply #'+ nums))) (1+ (length nums))))
#+end_src
See the documentation string of this macro for more information.
Best -- Eric
Eric S Fraga <address@hidden> writes:
> Hi,
>
> Quick question: I'd like to use a babel inline call to calculate
> something in a table based on other values in the table. Is this
> possible? Probably using elisp directly? If so, I cannot figure out
> what the magic incantation should be! I hope somebody can help.
>
> For illustration, I'd like to do something like this:
>
> #+source: f
> #+begin_src octave :var x=[1 3 5]
> sin(x)
> #+end_src
>
> | x1 | x2 | x3 | f |
> |----+----+----+--------------------------|
> | 1 | 3 | 5 | Apply call_f($1..$3) here |
>
> Thanks,
> eric
--
Eric Schulte
http://cs.unm.edu/~eschulte/