From: Dan Davison <davison@stats.ox.ac.uk>
To: Inquisitive Scientist <inquisitive.scientist@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: question about chaining function calls in org-babel
Date: Wed, 04 Aug 2010 22:08:36 -0400 [thread overview]
Message-ID: <87tyn9erq3.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <AANLkTin--bVLyjM_eQH+9n3MnHk5ONQCA8YV+2OS2C05@mail.gmail.com> (Inquisitive Scientist's message of "Wed, 4 Aug 2010 20:19:16 -0400")
Hi I.S.,
Inquisitive Scientist <inquisitive.scientist@gmail.com> writes:
> Dear Experts,
>
> I think org-babel is awesome but I'm having some trouble chaining
> together multiple function calls.
>
> Specifically, I would like to do something like the following
> #+tblname: fancier
> | mean |
> |--------|
> | #ERROR |
> #+TBLFM: @2$1='(sbe "python-mean" (x (sbe "tbl-example-data" (seed 4) (size
> (sbe "square" (x 4))))))
> but it doesn't work.
OK, first off, personally I would use a dedicated src block to construct
the complex chain of calls. So your most complex example can be done with
#+tblname:
| mean |
|---------------|
| 7.52617964952 |
#+TBLFM: @2$1='(sbe "chain")
#+srcname: chain
#+begin_src emacs-lisp :var x=python-mean(x=tbl-example-data(seed=4, size=square(x=4)))
x
#+end_src
[...]
> Try to do something even fancier and it doesn't work:
> #+tblname: fancier
> | mean |
> |------|
> | |
> #+TBLFM: @2$1='(sbe "python-mean" (x "tbl-example-data(seed=4,size=square(4))"))
This one works if we name the argument to square:
#+tblname: fancier
| mean |
|---------------|
| 7.52617964952 |
#+TBLFM: @2$1='(sbe "python-mean" (x "tbl-example-data(seed=4,size=square(x=4))"))
Beyond that, your examples feature one sbe nested inside another. For
example
| mean |
|--------|
| #ERROR |
#+TBLFM: @2$1='(sbe "python-mean" (x (sbe "tbl-example-data" (seed 4) (size 16))))
I *believe* that there is no expectation for this to work, because sbe
is an elisp function (well, a macro), and not a source block. In other
words, the first sbe is expecting a source block reference, whereas what
it gets is this lisp form:
(sbe "tbl-example-data" (seed 4) (size 16))
My guess is that sbe does not undertake to evaluate a lisp form
occurring in that context. But I admit that I still find these
complicated macros more or less incomprehensible, so we could do with
Eric's input here.
As for debugging, all I know of is to place print statements inside the
macro.
The docstring says
,----
| (defmacro sbe (source-block &rest variables)
| "Return the results of calling SOURCE-BLOCK with VARIABLES.
| Each element of VARIABLES should be a two
| element list, whose first element is the name of the variable and
| second element is a string of its value.
| [...]
| NOTE: by default string variable names are interpreted as
| references to source-code blocks. To force interpretation of a
| cell's value as a string,
| [...]
`----
Dan
>
> Try to do something even fancier with sbe and it doesn't work.
> #+tblname: fancier
> | mean |
> |------|
> | |
> #+TBLFM: @2$1='(sbe "python-mean" (x (sbe "tbl-example-data" (seed 4) (size
> square(4)))))
>
> One more try:
> #+tblname: fancier
> | mean |
> |--------|
> | #ERROR |
> #+TBLFM: @2$1='(sbe "python-mean" (x (sbe "tbl-example-data" (seed 4) (size
> (sbe "square" (x 4))))))
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode
next prev parent reply other threads:[~2010-08-05 2:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-05 0:19 question about chaining function calls in org-babel Inquisitive Scientist
2010-08-05 2:08 ` Dan Davison [this message]
2010-08-06 0:41 ` Eric Schulte
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.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tyn9erq3.fsf@stats.ox.ac.uk \
--to=davison@stats.ox.ac.uk \
--cc=emacs-orgmode@gnu.org \
--cc=inquisitive.scientist@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).