From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: Rick Frankel <rick@rickster.com>
Cc: emacs-orgmode@gnu.org, Charles Berry <ccberry@ucsd.edu>,
Eric Schulte <schulte.eric@gmail.com>
Subject: Re: input data for babel blocks
Date: Tue, 01 Oct 2013 17:16:49 +0200 [thread overview]
Message-ID: <m2had1nhr2.fsf@polytechnique.org> (raw)
In-Reply-To: <354a40d3e967378379adfecadf7d4af4@mail.rickster.com>
rick@rickster.com writes:
> You're close. The noweb ref should be a named src block which is
> executed, not expanded, so, (note the named shell source block and the
> parens in the noweb reference):
>
> #+name: testing
> #+BEGIN_SRC sh :results raw
> echo "["
> ls *.org | sed 's/$/;/'
> echo "]"
> #+END_SRC
>
> #+BEGIN_SRC ocaml :noweb yes
> let x =
> <<testing()>>
> in x
> #+END_SRC
Thanks a lot, that was the missing piece!
So, for the record, here is a way to convert a table as a list of tuples
for use in ocaml. Thanks again to everyone for the help in getting
there.
--8<---------------cut here---------------start------------->8---
#+name: mydata
| x | 1 | 1.4 |
| y | 2 | 4.5 |
| z | 3 | 7.0 |
#+name: table_to_tuple
#+BEGIN_SRC emacs-lisp :results raw :var v='()
(message
(concat "["
(mapconcat
(lambda (vlist)
(concat "("
(mapconcat
(lambda (val) (format "%S" val))
vlist
", ")
")"))
v
"; ")
"]"))
#+END_SRC
#+BEGIN_SRC ocaml :noweb yes
let x =
<<table_to_tuple(mydata)>>
in x
#+END_SRC
#+RESULTS:
: - : (string * int * float) list =
: [("x", 1, 1.4); ("y", 2, 4.5); ("z", 3, 7.)]
--8<---------------cut here---------------end--------------->8---
next prev parent reply other threads:[~2013-10-01 15:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-30 12:50 input data for babel blocks Alan Schmitt
2013-09-30 16:26 ` Charles Berry
2013-10-01 0:08 ` Eric Schulte
2013-10-01 8:12 ` Alan Schmitt
2013-10-01 11:58 ` Eric Schulte
2013-10-01 13:01 ` Alan Schmitt
2013-10-01 14:29 ` Rick Frankel
2013-10-01 15:16 ` Alan Schmitt [this message]
2013-10-01 15:29 ` Charles Berry
2013-10-01 17:16 ` Alan Schmitt
2013-10-01 19:06 ` Thomas S. Dye
2013-10-01 0:04 ` Eric Schulte
2013-10-01 8:15 ` Alan Schmitt
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=m2had1nhr2.fsf@polytechnique.org \
--to=alan.schmitt@polytechnique.org \
--cc=ccberry@ucsd.edu \
--cc=emacs-orgmode@gnu.org \
--cc=rick@rickster.com \
--cc=schulte.eric@gmail.com \
/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).