From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [babel] inline call within table formula? Date: Sun, 10 Jul 2011 09:54:57 -0600 Message-ID: <87aacmruyc.fsf@gmail.com> References: <87wrfs6bro.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:60721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfwMU-0003lj-BA for emacs-orgmode@gnu.org; Sun, 10 Jul 2011 11:56:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QfwMS-0007HZ-IS for emacs-orgmode@gnu.org; Sun, 10 Jul 2011 11:56:01 -0400 Received: from mail-pv0-f169.google.com ([74.125.83.169]:44117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfwMS-0007HR-5U for emacs-orgmode@gnu.org; Sun, 10 Jul 2011 11:56:00 -0400 Received: by pvc12 with SMTP id 12so2560389pvc.0 for ; Sun, 10 Jul 2011 08:55:59 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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 @1..@6)) #+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 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/