From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Possible Calc support for Org-Babel? Date: Tue, 01 Mar 2011 10:34:07 -0700 Message-ID: <87vd024u2q.fsf@gmail.com> References: <878w1ani4w.fsf@ucl.ac.uk> <87eib1dxll.fsf@gmail.com> <87hbcvnpr4.fsf@dustycloud.org> <87zkpn8j10.fsf@gmail.com> <87fwrdoi43.fsf@pinto.chemeng.ucl.ac.uk> <87lj1188pe.fsf@gmail.com> <87oc5wvxbm.fsf@ucl.ac.uk> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=53946 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PuTo6-0007il-6D for emacs-orgmode@gnu.org; Tue, 01 Mar 2011 12:56:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PuTo4-0001eA-Ti for emacs-orgmode@gnu.org; Tue, 01 Mar 2011 12:56:22 -0500 Received: from mail-gw0-f51.google.com ([74.125.83.51]:65188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PuTo4-0001e4-RU for emacs-orgmode@gnu.org; Tue, 01 Mar 2011 12:56:20 -0500 Received: by gwb15 with SMTP id 15so2612261gwb.38 for ; Tue, 01 Mar 2011 09:56:20 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric S Fraga Cc: emacs-orgmode@gnu.org, Matthew Oesting Eric S Fraga writes: > "Eric Schulte" writes: > >> Eric S Fraga writes: > > [...] > >>> >>> Further on this, any suggestions on how to pass a vector variable to >>> calc using babel? I tried >>> >>> #+begin-src org >>> #+begin_src calc :var y=[1 2 3] >>> 3 y >>> #+end_src >>> #+end_src >>> >>> but get an error that says >>> >>> : Bad format in variable contents: Expected a number >>> >>> I've tried putting the vector in quotes but that doesn't help either. >>> Is this maybe not possible? >>> >> >> With the newest version of Org-mode, I'm now getting the following >> output. >> >> #+begin_src calc :var y=[1 2 3] >> 3 y >> #+end_src >> #+results: >> : (3, 6) >> >> Does this look correct? >> >> Best -- Eric > > This does not look correct: assuming my knowledge of calc is correct, > the result should be the scalar 3 multiplied by each of the vector > elements. I don't understand how =(3, 6)= can be the output of =3 y=... > > The strange thing is that this doesn't work at all for me (with git as > of a few minutes ago): I still get the error message > > : byte-code: Bad format in variable contents: Expected a number > > However, if I put the vector in double quotes, it works: > > #+begin_src calc :var y="[1 2 3]" > 3 y > #+end_src > > #+results: > : [3, 6, 9] > > *but* if I subsequently remove the double quotes, it doesn't work and if > put them back, it no longer works either. I am confused... there's > like a hysteresis loop in org babel :( > > Any suggestions on how to debug this are welcome, of course. Oh, I just got an even stranger result, with the latest from git... #+begin_src calc :var y=[1 2 3] 3 y #+end_src #+results: : 3 hline something is most certainly wrong... Alright, I've made two changes, first, it is now possible to pass elisp vectors through to code blocks, e.g., #+begin_src emacs-lisp :var data=[1 2 3] (elt data 1) #+end_src #+results: : 2 Second, I've added a slightly hackey but seemingly necessary post-processing step to a call to calc-eval in ob-calc to remove quotes from vectors. This allows vector processing to take place---at least as far as my limited calc knowledge is concerned. For example; #+begin_src calc :var y=[1 2 3] 3 y #+end_src #+results: : [3, 6, 9] Hope this helps -- Cheers -- Eric