From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Babel and clojure vars Date: Tue, 27 Sep 2016 15:45:31 -0400 Message-ID: <87twd1unxg.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boyKN-0001lM-Q3 for emacs-orgmode@gnu.org; Tue, 27 Sep 2016 15:46:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1boyKJ-0002WN-SA for emacs-orgmode@gnu.org; Tue, 27 Sep 2016 15:46:07 -0400 Received: from [195.159.176.226] (port=37121 helo=blaine.gmane.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1boyKJ-0002Qm-L5 for emacs-orgmode@gnu.org; Tue, 27 Sep 2016 15:46:03 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1boyJu-0004qQ-RM for emacs-orgmode@gnu.org; Tue, 27 Sep 2016 21:45:38 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Lawrence Bottorff 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