The collection class of the <code>:results</code> header argument supports two mutually exclusive options: <code>value</code> and <code>output</code>. When <code>:results value</code> is specified, Org takes the body of the source block, creates a function with that body, evaluates the function with <code>julia</code>, stores the result in a <code>.csv</code> file, then converts the <code>.csv</code> file to an <code>emacs-lisp</code> table, and finally inserts the table in the buffer. <i>Whew!</i> The bottom line? Hit <code>C-c C-c</code> in the following code block.
As expected, the output of the command was a <code>2x3</code> array and Org inserted a table into the buffer. This functionality is relatively powerful with other languages such as R, for instance, because <code>ob-R.el</code> works with <code>TAB</code> separated files instead and <code>read.table</code> in R supports reading of much more varied data types compared to <code>readcsv</code> in <code>julia</code> (at the present time). Nevertheless, the functionality exists in <code>julia</code> and as time passes and <code>julia</code> adds more options we'll add more, too.
We will get a lot more mileage out of the <code>:results output</code> option. Every command in the src block body is evaluated by <code>julia</code> in turn and the results are placed in the buffer to be typeset in a verbatim environment. This option is similar to typing commands in <code>julia</code> at an interactive session. The analogy isn't exact, though, because at an interactive session it is one (1) command in, one (1) result out. Multiple lines in an org SRC block in contrast have RESULTS which are lumped together. Like this: (do <code>C-c C-c</code>)
It is sometimes helpful to split up SRC blocks into smaller chunks so that buildup of RESULTS does not get out of hand. Also, specific to <code>julia</code> we can sometimes put a semicolon at the end of the command to suppress output, like this:
@@ -148,8 +149,47 @@ place and initialized properly. Now the fun begins.
** :results value
The collection class of the =:results= header argument supports two mutually exclusive options: =value= and =output=. When =:results value= is specified, Org takes the body of the source block, creates a function with that body, evaluates the function with =julia=, stores the result in a =.csv= file, then converts the =.csv= file to an =emacs-lisp= table, and finally inserts the table in the buffer. /Whew!/ The bottom line? Hit =C-c C-c= in the following code block.
As expected, the output of the command was a =2x3= array and Org inserted a table into the buffer. This functionality is relatively powerful with other languages such as R, for instance, because =ob-R.el= works with =TAB= separated files instead and =read.table= in R supports reading of much more varied data types compared to =readcsv= in =julia= (at the present time). Nevertheless, the functionality exists in =julia= and as time passes and =julia= adds more options we'll add more, too.
** :results output
We will get a lot more mileage out of the =:results output= option. Every command in the src block body is evaluated by =julia= in turn and the results are placed in the buffer to be typeset in a verbatim environment. This option is similar to typing commands in =julia= at an interactive session. The analogy isn't exact, though, because at an interactive session it is one (1) command in, one (1) result out. Multiple lines in an org SRC block in contrast have RESULTS which are lumped together. Like this: (do =C-c C-c=)
#+BEGIN_SRC julia
2 + 3
print("hello")
sqrt(5)
#+END_SRC
#+RESULTS:
: 5
: hello
: 2.23606797749979
It is sometimes helpful to split up SRC blocks into smaller chunks so that buildup of RESULTS does not get out of hand. Also, specific to =julia= we can sometimes put a semicolon at the end of the command to suppress output, like this:
#+BEGIN_SRC julia
2 + 3;
print("hello");
sqrt(5);
#+END_SRC
#+RESULTS:
:
: hello
Notice the outer two results were suppressed, but not the middle one.
* Graphics
The most stable and fully featured of the =julia= graphics packages at
...
...
@@ -214,6 +254,9 @@ mode]]. Assuming you've done that, evaluate the following code block.
file(p, "example1.png")
#+END_SRC
#+RESULTS:
[[file:example1.png]]
The code block evaluates the command =file(p, "example1.png")=, which
tells =julia= to write the graph to a =.png= file (also available are
=.pdf=, =.svg=, and =.eps=, though none of those can be inserted in
\title{Org-mode and \texttt{julia}: an introduction}
\hypersetup{
pdfkeywords={},
pdfsubject={},
...
...
@@ -173,8 +173,51 @@ place and initialized properly. Now the fun begins.
\subsection[:results value]{:results value}
\label{sec-2-1}
The collection class of the \texttt{:results} header argument supports two mutually exclusive options: \texttt{value} and \texttt{output}. When \texttt{:results value} is specified, Org takes the body of the source block, creates a function with that body, evaluates the function with \texttt{julia}, stores the result in a \texttt{.csv} file, then converts the \texttt{.csv} file to an \texttt{emacs-lisp} table, and finally inserts the table in the buffer. \emph{Whew!} The bottom line? Hit \texttt{C-c C-c} in the following code block.
As expected, the output of the command was a \texttt{2x3} array and Org inserted a table into the buffer. This functionality is relatively powerful with other languages such as R, for instance, because \texttt{ob-R.el} works with \texttt{TAB} separated files instead and \texttt{read.table} in R supports reading of much more varied data types compared to \texttt{readcsv} in \texttt{julia} (at the present time). Nevertheless, the functionality exists in \texttt{julia} and as time passes and \texttt{julia} adds more options we'll add more, too.
\subsection[:results output]{:results output}
\label{sec-2-2}
We will get a lot more mileage out of the \texttt{:results output} option. Every command in the src block body is evaluated by \texttt{julia} in turn and the results are placed in the buffer to be typeset in a verbatim environment. This option is similar to typing commands in \texttt{julia} at an interactive session. The analogy isn't exact, though, because at an interactive session it is one (1) command in, one (1) result out. Multiple lines in an org SRC block in contrast have RESULTS which are lumped together. Like this: (do \texttt{C-c C-c})
\begin{verbatim}
2 + 3
print("hello")
sqrt(5)
\end{verbatim}
\begin{verbatim}
5
hello
2.23606797749979
\end{verbatim}
It is sometimes helpful to split up SRC blocks into smaller chunks so that buildup of RESULTS does not get out of hand. Also, specific to \texttt{julia} we can sometimes put a semicolon at the end of the command to suppress output, like this:
\begin{verbatim}
2 + 3;
print("hello");
sqrt(5);
\end{verbatim}
\begin{verbatim}
hello
\end{verbatim}
Notice the outer two results were suppressed, but not the middle one.
\section[Graphics]{Graphics}
\label{sec-3}
...
...
@@ -243,6 +286,8 @@ mode}. Assuming you've done that, evaluate the following code block.