* Babel and clojure vars
@ 2016-09-27 19:03 Lawrence Bottorff
2016-09-27 19:45 ` Nick Dokos
0 siblings, 1 reply; 2+ messages in thread
From: Lawrence Bottorff @ 2016-09-27 19:03 UTC (permalink / raw)
To: emacs-orgmode Mailinglist
[-- Attachment #1: Type: text/plain, Size: 416 bytes --]
Once before I was wondering why :vars doesn't seem to work properly with
clojure. This works:
#+begin_src clojure :var a='(1 2 3 4 5)
(count a)
#+end_src
#+RESULTS:
: 5
as well as this
#+begin_src emacs-lisp :var a=(number-sequence 1 5)
a
#+end_src
#+RESULTS: num-seq-test1
| 1 | 2 | 3 | 4 | 5 |
but this is a no go. . . .
#+begin_src clojure c=(range 10)
(count c)
#+end_src
eval doesn't help, either.
LB
[-- Attachment #2: Type: text/html, Size: 808 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Babel and clojure vars
2016-09-27 19:03 Babel and clojure vars Lawrence Bottorff
@ 2016-09-27 19:45 ` Nick Dokos
0 siblings, 0 replies; 2+ messages in thread
From: Nick Dokos @ 2016-09-27 19:45 UTC (permalink / raw)
To: emacs-orgmode
Lawrence Bottorff <borgauf@gmail.com> writes:
> Once before I was wondering why :vars doesn't seem to work properly with clojure. This works:
>
> #+begin_src clojure :var a='(1 2 3 4 5)
> (count a)
> #+end_src
>
> #+RESULTS:
> : 5
>
> as well as this
>
> #+begin_src emacs-lisp :var a=(number-sequence 1 5)
> a
> #+end_src
>
> #+RESULTS: num-seq-test1
> | 1 | 2 | 3 | 4 | 5 |
>
> but this is a no go. . . .
>
> #+begin_src clojure c=(range 10)
> (count c)
> #+end_src
>
Is `range' a clojure function? If so, that's expected:
(info "(org) var") says:
,----
| The values passed to arguments can either be literal values,
| references, or Emacs Lisp code (see *note Emacs Lisp evaluation of
| variables: var.).
`----
[The syntax is wrong too: it should read
#+begin_src clojure :var c=(range 10)
(count c)
#+end_src
but it's not going to work unless you define an emacs-lisp function called range
and teach it to emacs.]
The following works (I don't have clojure installed here, so I replaced it with scheme):
--8<---------------cut here---------------start------------->8---
#+BEGIN_SRC emacs-lisp
(defun range (N)
(if (<= N 1)
(list N)
(nconc (range (- N 1)) (list N))))
#+END_SRC
#+begin_src scheme :var c=(range 10)
(define (count l)
(if (null? l)
0
(1+ (count (cdr l)))))
(count c)
#+end_src
#+RESULTS:
: 10
--8<---------------cut here---------------end--------------->8---
--
Nick
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-09-27 19:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-27 19:03 Babel and clojure vars Lawrence Bottorff
2016-09-27 19:45 ` Nick Dokos
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.