emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alef Farah <afarah@inf.ufrgs.br>
To: emacs-orgmode@gnu.org
Subject: How to pass an array of integers to a C code block with :var?
Date: Tue, 9 Aug 2016 15:32:01 -0300	[thread overview]
Message-ID: <20160809183201.GA1485@thinkpad> (raw)

Hi,

I am trying to use babel's :var to pass an array of integers to a C code
block. I can do it like this:

#+begin_src C :var arr='(1 2) :includes <stdio.h>
printf("%d %d\n", arr[0], arr[1]);
#+end_src

However, I wish to assign the output of another code block to the
variable, like this:

#+name: input
#+begin_src sh
seq 2
#+end_src

#+begin_src C :var arr=input :includes <stdio.h>
printf("%d %d\n", arr[0], arr[1]);
#+end_src

But this way, "arr" is evaluated as a string. I tried formatting the
output of the input code block as '(1 2), but it is still evaluated as a
string.

Is there any way to do this without manually grabbing the list from the
results of the input code block and pasting it in the C block?

                 reply	other threads:[~2016-08-09 18:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20160809183201.GA1485@thinkpad \
    --to=afarah@inf.ufrgs.br \
    --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).