emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [ob-calc] bug when given table data as a variable
@ 2014-03-05  3:34 Daniel Hackney
  2014-03-06 22:10 ` Eric Schulte
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Hackney @ 2014-03-05  3:34 UTC (permalink / raw)
  To: emacs-orgmode

I am trying to use data from a table in a calc source block, but I get
the following error when trying to eval the block:

#+BEGIN_EXAMPLE
math-format-stack-value: Wrong type argument: symbolp, 10
#+END_EXAMPLE

Here is an example file which demonstrates the problem:

#+BEGIN_EXAMPLE
Org version: 8.2.5h (org-20140224 from package)
Emacs version: 24.3.1

Run after starting Emacs with =emacs -Q=

#+BEGIN_SRC elisp
(add-to-list 'org-babel-load-languages '(calc . t))
(require 'ob-calc)
#+END_SRC

#+NAME: the-table
| a |  b |   c |
|---+----+-----|
| 1 | 10 | 100 |
| 2 | 20 | 200 |
| 3 | 30 | 300 |
| 4 | 40 | 400 |

#+BEGIN_SRC calc :var data=the-table[,1]
1
#+END_SRC

#+BEGIN_SRC elisp :var data=the-table[,1]
(format "%s" data)
#+END_SRC
#+END_EXAMPLE

I'm not familiar with the workings of calc, but is there a workaround?

P.S. Please CC me in replies since I'm not subscribed to the list.

--
Daniel Hackney

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ob-calc] bug when given table data as a variable
  2014-03-05  3:34 [ob-calc] bug when given table data as a variable Daniel Hackney
@ 2014-03-06 22:10 ` Eric Schulte
  2014-03-07  1:02   ` Daniel Hackney
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Schulte @ 2014-03-06 22:10 UTC (permalink / raw)
  To: Daniel Hackney; +Cc: emacs-orgmode

Org-mode's calc support is very limited.  I think someone with a working
knowledge of how calc uses vectors would need to add table support.
Unfortunately calc experts seem to be few and far between.

Best,

Daniel Hackney <dan@haxney.org> writes:

> I am trying to use data from a table in a calc source block, but I get
> the following error when trying to eval the block:
>
> #+BEGIN_EXAMPLE
> math-format-stack-value: Wrong type argument: symbolp, 10
> #+END_EXAMPLE
>
> Here is an example file which demonstrates the problem:
>
> #+BEGIN_EXAMPLE
> Org version: 8.2.5h (org-20140224 from package)
> Emacs version: 24.3.1
>
> Run after starting Emacs with =emacs -Q=
>
> #+BEGIN_SRC elisp
> (add-to-list 'org-babel-load-languages '(calc . t))
> (require 'ob-calc)
> #+END_SRC
> #+NAME: the-table
> | a |  b |   c |
> |---+----+-----|
> | 1 | 10 | 100 |
> | 2 | 20 | 200 |
> | 3 | 30 | 300 |
> | 4 | 40 | 400 |
>
> #+BEGIN_SRC calc :var data=the-table[,1]
> 1
> #+END_SRC
> #+BEGIN_SRC elisp :var data=the-table[,1]
> (format "%s" data)
> #+END_SRC
> #+END_EXAMPLE
>
> I'm not familiar with the workings of calc, but is there a workaround?
>
> P.S. Please CC me in replies since I'm not subscribed to the list.
>
> --
> Daniel Hackney
>

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [ob-calc] bug when given table data as a variable
  2014-03-06 22:10 ` Eric Schulte
@ 2014-03-07  1:02   ` Daniel Hackney
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Hackney @ 2014-03-07  1:02 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

Eric Schulte <schulte.eric@gmail.com> wrote:
> Org-mode's calc support is very limited. I think someone with a
> working knowledge of how calc uses vectors would need to add table
> support. Unfortunately calc experts seem to be few and far between.

Looking at the calc source code was not terribly helpful, since it is
barely documented. The info page can help somewhat, though.

Doing a little bit of digging, it looks like you can bind variables for
=calc-eval= like so:

#+BEGIN_SRC elisp
(let ((var-a "[1, 2, 3]"))
 (calc-eval "evalv(reduce(add, a))"))
#+END_SRC

#+RESULTS:
: 6

This pattern could be used for variable binding. It would mean wrapping
the code to be evaluated in =evalv=. If I get some time, I might
investigate writing a patch to do this.

--
Daniel Hackney

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-07  1:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-05  3:34 [ob-calc] bug when given table data as a variable Daniel Hackney
2014-03-06 22:10 ` Eric Schulte
2014-03-07  1:02   ` Daniel Hackney

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).