* help with porting babel example on worg to latest version
@ 2014-01-06 7:03 Christian Wittern
2014-01-06 9:43 ` Bastien
[not found] ` <1389004050.53626.YahooMailNeo@web171302.mail.ir2.yahoo.com>
0 siblings, 2 replies; 5+ messages in thread
From: Christian Wittern @ 2014-01-06 7:03 UTC (permalink / raw)
To: Org Mode Mailing List
Hi there,
I am trying to understand how to use information from an org table as input
for a babel function.
For this purpose, I looked at the example at
http://orgmode.org/worg/org-contrib/babel/intro.html#arguments-to-source-code-blocks
It seems that this is using the old syntax, eg. #+tblname, which seems to be
just #+name now. But even with this change I can not reproduce the result.
With the following code, I get the message "Symbol's value as variable is
void: fib-inputs" when doing C-c on the src. I am sure there are more
changes I need to make, but I can't figure it out. Any help appreciated.
Here is the code so far:
#+name: fibonacci-inputs
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
#+name: fibonacci-seq(fib-inputs=fibonacci-inputs)
#+begin_src emacs-lisp
(defun fibonacci (n)
(if (or (= n 0) (= n 1))
n
(+ (fibonacci (- n 1)) (fibonacci (- n 2)))))
(mapcar (lambda (row)
(mapcar #'fibonacci row)) fib-inputs)
#+end_src
All the best,
Christian
--
Christian Wittern, Kyoto
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: help with porting babel example on worg to latest version
2014-01-06 7:03 help with porting babel example on worg to latest version Christian Wittern
@ 2014-01-06 9:43 ` Bastien
[not found] ` <1389004050.53626.YahooMailNeo@web171302.mail.ir2.yahoo.com>
1 sibling, 0 replies; 5+ messages in thread
From: Bastien @ 2014-01-06 9:43 UTC (permalink / raw)
To: Christian Wittern; +Cc: Org Mode Mailing List
Hi Christian,
Christian Wittern <cwittern@gmail.com> writes:
> #+name: fibonacci-inputs
> | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
> | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
>
>
> #+name: fibonacci-seq(fib-inputs=fibonacci-inputs)
> #+begin_src emacs-lisp
> (defun fibonacci (n)
> (if (or (= n 0) (= n 1))
> n
> (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))
>
> (mapcar (lambda (row)
> (mapcar #'fibonacci row)) fib-inputs)
> #+end_src
I think you need
#+headers: fibonacci-seq(fib-inputs=fibonacci-inputs)
instead of #+name above.
--
Bastien
^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <1389004050.53626.YahooMailNeo@web171302.mail.ir2.yahoo.com>]
* Re: help with porting babel example on worg to latest version
[not found] ` <1389004050.53626.YahooMailNeo@web171302.mail.ir2.yahoo.com>
@ 2014-01-06 10:28 ` Miguel Ruiz
2014-01-06 12:00 ` patch for worg (was:Re: help with porting babel example on worg to latest version) Christian Wittern
1 sibling, 0 replies; 5+ messages in thread
From: Miguel Ruiz @ 2014-01-06 10:28 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 1834 bytes --]
What's the problem with:
#+name: fibonacci-inputs
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
#+name: fibonacci-seq
#+begin_src emacs-lisp :var fib-inputs=fibonacci-inputs
(defun fibonacci (n)
(if (or (= n 0) (= n 1))
n
(+ (fibonacci (- n 1)) (fibonacci (- n 2)))))
(mapcar (lambda (row)
(mapcar #'fibonacci row)) fib-inputs)
#+end_src
#+RESULTS:
fibonacci-seq
| 1 | 1 | 2 | 3 | 5 | 8 | 13 | 21 | 34 | 55 |
| 1 | 3 | 8 | 21 | 55 | 144 | 377 | 987 | 2584 | 6765 |
?
El Lunes 6 de enero de 2014 8:03, Christian Wittern <cwittern@gmail.com> escribió:
Hi there,
I am trying to understand how to use information from an org table as input
for a babel function.
For this purpose, I
looked at the example at
http://orgmode.org/worg/org-contrib/babel/intro.html#arguments-to-source-code-blocks
It seems that this is using the old syntax, eg. #+tblname, which seems to be
just #+name now. But even with this change I can not reproduce the result.
With the following code, I get the message "Symbol's value as variable is
void: fib-inputs" when doing C-c on the src. I am sure there are more
changes I need to make, but I can't figure it out. Any help appreciated.
Here is the code so far:
#+name: fibonacci-inputs
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
#+name: fibonacci-seq(fib-inputs=fibonacci-inputs)
#+begin_src emacs-lisp
(defun fibonacci (n)
(if (or (= n 0) (= n 1))
n
(+ (fibonacci (- n 1)) (fibonacci (- n 2)))))
(mapcar (lambda (row)
(mapcar #'fibonacci row)) fib-inputs)
#+end_src
All the best,
Christian
--
Christian Wittern, Kyoto
[-- Attachment #2: Type: text/html, Size: 4992 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* patch for worg (was:Re: help with porting babel example on worg to latest version)
[not found] ` <1389004050.53626.YahooMailNeo@web171302.mail.ir2.yahoo.com>
2014-01-06 10:28 ` Miguel Ruiz
@ 2014-01-06 12:00 ` Christian Wittern
2014-01-06 12:57 ` patch for worg Bastien
1 sibling, 1 reply; 5+ messages in thread
From: Christian Wittern @ 2014-01-06 12:00 UTC (permalink / raw)
To: Org Mode Mailing List; +Cc: Miguel Ruiz
[-- Attachment #1: Type: text/plain, Size: 355 bytes --]
Thanks Miguel,
On 2014-01-06, 19:27, Miguel Ruiz wrote:
>
> #+begin_src emacs-lisp :var fib-inputs=fibonacci-inputs
>
This magic line does the trick.
I created a patch for this, attached. I tried to follow the instructions,
but since this is the first time, please be patient if something went wrong.
Cheers, Christian
--
Christian Wittern, Kyoto
[-- Attachment #2: 0001-Adopted-the-fibonacci-example-to-Org-8.x-syntax.patch --]
[-- Type: text/plain, Size: 1614 bytes --]
From 08b07bbdd88bd78dd880a726f875ac167d4e2597 Mon Sep 17 00:00:00 2001
From: Chris Wittern <chris@mbp3>
Date: Mon, 6 Jan 2014 20:57:48 +0900
Subject: [PATCH] Adopted the fibonacci example to Org 8.x syntax
---
org-contrib/babel/intro.org | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/org-contrib/babel/intro.org b/org-contrib/babel/intro.org
index 88eefc9..99a25a2 100644
--- a/org-contrib/babel/intro.org
+++ b/org-contrib/babel/intro.org
@@ -498,7 +498,7 @@ Now we use the source block:
Here is the Org-mode table that is passed to =fibonacci-seq=:
-#+tblname: fibonacci-inputs
+#+name: fibonacci-inputs
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
@@ -508,8 +508,8 @@ The table looks like this in the Org-mode buffer:
: | 2 | 4 | 6 | 8 | 10 | 12 | 14 | 16 | 18 | 20 |
The [[http://www.gnu.org/software/emacs/manual/elisp.html][Emacs Lisp]] source code:
-#+name: fibonacci-seq(fib-inputs=fibonacci-inputs)
-#+begin_src emacs-lisp
+#+name: fibonacci-seq
+#+begin_src emacs-lisp :var fib-inputs=fibonacci-inputs
(defun fibonacci (n)
(if (or (= n 0) (= n 1))
n
@@ -520,8 +520,8 @@ The [[http://www.gnu.org/software/emacs/manual/elisp.html][Emacs Lisp]] source c
#+end_src
In the Org-mode buffer the function looks like this:
-: #+name: fibonacci-seq(fib-inputs=fibonacci-inputs)
-: #+begin_src emacs-lisp
+: #+name: fibonacci-seq
+: #+begin_src emacs-lisp :var fib-inputs=fibonacci-inputs
: (defun fibonacci (n)
: (if (or (= n 0) (= n 1))
: n
--
1.8.3.4 (Apple Git-47)
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-01-06 12:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-06 7:03 help with porting babel example on worg to latest version Christian Wittern
2014-01-06 9:43 ` Bastien
[not found] ` <1389004050.53626.YahooMailNeo@web171302.mail.ir2.yahoo.com>
2014-01-06 10:28 ` Miguel Ruiz
2014-01-06 12:00 ` patch for worg (was:Re: help with porting babel example on worg to latest version) Christian Wittern
2014-01-06 12:57 ` patch for worg Bastien
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).