[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Preserving the geometry of a table range
From: |
Jarmo Hurri |
Subject: |
Re: [O] Preserving the geometry of a table range |
Date: |
Sun, 26 Aug 2012 11:45:50 +0300 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
Greetings Michael.
I can try. Here is an example of the desired low-level functionality
with a simple function. The lookup functions would be built on this.
Does this help?
* an example of low level functionality
Here is an example of an elisp function working on a range as a list
of rows. This one first finds the product of the elements on each
row, and then sums up these products.
#+BEGIN_SRC emacs-lisp
(defun sum-row-prods (rows)
(apply '+ (mapcar (lambda (row) (apply '* row)) rows)))
#+END_SRC
#+RESULTS:
: sum-row-prods
Then here we have a table in which the element at @4$1 is given by
applying the function sum-row-prods to a specific list of
lists. This works already in org mode, since in the formula for @4$1
the list of lists is given as a constant. The formula for @4$2
illustrates the desired functionality, that is, being able to apply
the function sum-row-prods to range @address@hidden The result should be
#+BEGIN_SRC emacs-lisp
(sum-row-prods '((2 3) (4 5)))
#+END_SRC
#+RESULTS:
: 26
but now it naturally gives an error, since the argument to
sum-row-prods is a list, not a list of lists (rows).
| a | b |
|----+--------|
| 2 | 3 |
| 4 | 5 |
| 10 | #ERROR |
#+tblfm: @4$1='(sum-row-prods '((-4 1) (-2 -7)));N::@4$2='(sum-row-prods
'(@address@hidden));N
I don't know what the new syntax for referring to a range as a list
of rows should look like.
--
Jarmo