[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] How to pass an array of integers to a C code block with :var?
From: |
Alef Farah |
Subject: |
[O] How to pass an array of integers to a C code block with :var? |
Date: |
Tue, 9 Aug 2016 15:32:01 -0300 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
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?
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [O] How to pass an array of integers to a C code block with :var?,
Alef Farah <=