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 via email to