emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: Eric S Fraga <e.fraga@ucl.ac.uk>
Cc: emacs-orgmode@gnu.org, Matthew Oesting <oestingm@me.com>
Subject: Re: Possible Calc support for Org-Babel?
Date: Tue, 01 Mar 2011 10:34:07 -0700	[thread overview]
Message-ID: <87vd024u2q.fsf@gmail.com> (raw)
In-Reply-To: 87oc5wvxbm.fsf@ucl.ac.uk

Eric S Fraga <e.fraga@ucl.ac.uk> writes:

> "Eric Schulte" <schulte.eric@gmail.com> writes:
>
>> Eric S Fraga <e.fraga@ucl.ac.uk> 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

  reply	other threads:[~2011-03-01 17:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-03 22:42 Possible Calc support for Org-Babel? Eric S Fraga
2010-11-04 13:24 ` Eric Schulte
2010-11-04 14:13   ` Eric S Fraga
2010-11-04 14:42   ` Sébastien Vauban
2010-11-04 15:33     ` Eric Schulte
2010-11-04 16:02       ` Sébastien Vauban
2010-11-04 16:23         ` Eric Schulte
2011-01-27  0:39   ` Christopher Allan Webber
2011-02-23  4:35     ` Eric Schulte
2011-02-24 10:13       ` Eric S Fraga
2011-02-27 21:32         ` Eric Schulte
2011-02-28 18:16           ` Eric S Fraga
2011-03-01 17:34             ` Eric Schulte [this message]
2011-03-01 20:10               ` Eric S Fraga
2011-03-07  9:16               ` Eric S Fraga
  -- strict thread matches above, loose matches on Subject: below --
2011-03-01 20:48 orgmode
2010-10-22 17:17 Matthew Oesting
2010-10-26 18:37 ` Eric Schulte
2010-10-29  6:42   ` Eric Schulte
2010-10-29  7:13     ` Carsten Dominik
2010-10-29 11:14     ` Eric S Fraga
2010-10-29 14:43       ` Eric Schulte
2010-10-29 16:22         ` Eric Schulte
2010-10-29 19:53         ` Eric S Fraga
2010-10-29 20:26           ` Eric Schulte
     [not found]             ` <87hbg4pooh.fsf@ucl.ac.uk>
     [not found]               ` <871v7879x5.fsf@gmail.com>
2010-10-30 20:54                 ` Eric S Fraga
2010-11-03 20:10                   ` Eric Schulte
2010-10-29 11:27     ` Sébastien Vauban

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=87vd024u2q.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=oestingm@me.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).