emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jarmo Hurri <jarmo.hurri@syk.fi>
To: emacs-orgmode@gnu.org
Subject: Re: Preserving the geometry of a table range
Date: Sun, 26 Aug 2012 11:45:50 +0300	[thread overview]
Message-ID: <87harq59dt.fsf@syk.fi> (raw)
In-Reply-To: CALn3zohS_Za6w-xf7d0an1auxwzr0DhrT0e8Lffw_N1dcJ2yDQ@mail.gmail.com


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 @2$1..@3$2. 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 '(@2$1..@3$2));N

  I don't know what the new syntax for referring to a range as a list
  of rows should look like.

--

Jarmo

  reply	other threads:[~2012-08-26  8:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-26  6:54 Preserving the geometry of a table range Jarmo Hurri
2012-08-26  7:10 ` Michael Brand
2012-08-26  8:45   ` Jarmo Hurri [this message]
2012-08-26 18:58     ` Michael Brand
2012-08-27 12:33 ` Michael Brand
2012-09-02 14:53   ` Small contrib: lookup (was "Preserving the geometry of a table range") Jarmo Hurri

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=87harq59dt.fsf@syk.fi \
    --to=jarmo.hurri@syk.fi \
    --cc=emacs-orgmode@gnu.org \
    /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).