emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Thorsten Jolitz <tjolitz@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Include results in a table
Date: Tue, 28 Oct 2014 11:44:26 +0100	[thread overview]
Message-ID: <8738a8fp85.fsf@gmail.com> (raw)
In-Reply-To: 544F6B07.6080304@thierry-pelle.eu

abonnements <abonnements@thierry-pelle.eu> writes:

> Hi, thank you for your answer.
>
> Your solution is OK but only for the example I gave (2 or 3
> results). In practice I have about 10 results and the number of them
> may be variable...  Furthermore :vars does not work on my version (I
> must use :var x=A :var y=B)...

:vars was just a typo then ....

#+NAME: A
#+BEGIN_SRC emacs-lisp :results raw
 (+ 2 2)
#+END_SRC

#+results: A
4

#+NAME: B
#+BEGIN_SRC emacs-lisp :results raw
 (/ 2 2)
#+END_SRC

#+results: B
1

#+BEGIN_SRC emacs-lisp
  (org-element-map (org-element-parse-buffer) 'src-block
    (lambda (--block)
      (let ((nm (org-element-property :name --block)))
        (when nm
          (let ((val (org-element-property :value --block)))
            (list nm (eval (car (read-from-string val)))))))))
#+END_SRC

#+results:
| A | 4 |
| B | 1 |


> Ta.
> Thierry
>  
> Hello,
>
>> I have somethink like that
>>
>> #+call: gen(A)
>> #+results: A
>> : 10
>>
>> #+call: gen(B)
>> #+results: B
>> : 20
>>
>> Is there a simple mean to aggregate the results in a table, i.e to get
>> | A | 10 |
>> | B | 20 |
>>
>> I think some lisp can do that but as a beginner... but as I want to 
>> learn you can suggest a somewhat complicated solution or a simple idea.
>> Thanks.
>
> you could define a 3rd block C that takes the results from block A and B
> as variable via :vars x=A y=B (A and B must be named blocks for this,
> use a #+NAME: A line) and then do (list A x B y) in block C and use the
> :results format that outputs a list as a table (often it is the default,
> otherwise try :results table or so).

-- 
cheers,
Thorsten

  reply	other threads:[~2014-10-28 10:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-28 10:08 Include results in a table abonnements
2014-10-28 10:44 ` Thorsten Jolitz [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-10-28  9:02 abonnements
2014-10-28  9:34 ` Thorsten Jolitz
2014-10-28 10:54 ` Michael Brand

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=8738a8fp85.fsf@gmail.com \
    --to=tjolitz@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /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).