Carsten Dominik <[EMAIL PROTECTED]> writes:

[...]

> Well, you can do this by leaving the formatting to the function
> instead of the formula under the table:
>
>
> (defun my-wmean (values weights)
>  (let ((vsum 0) (wsum 0))
>    (while (and values weights)
>      (setq v (pop values) w (pop weights))
>      (unless (equal "" v)
>       (setq vsum (+ vsum (* (string-to-number w) (string-to-number v)))
>             wsum (+ wsum (string-to-number w)))))
>    (if (= vsum 0) "" (format "%.1f" (/ vsum wsum)))))
>
>
> The you could use this as your equation:
>
> |           | Coeff. |    0.2 |    0.5 |      1 |
> |-----------+--------+--------+--------+--------|
> | Name      |        | Test 1 | Test 2 | Test 3 |
> |-----------+--------+--------+--------+--------|
> | Student A |   10.0 |     15 |     12 |      8 |
> | Student B |   12.7 |        |     16 |     11 |
> | Student C |        |        |        |        |
> #+TBLFM: $2='(my-wmean '($3..$5) '(@[EMAIL PROTECTED]));E

This raises an issue I've been running into recently, If I have a
multi-line elisp function (I guess same issue would apply for multi-line
shell commands) that I want to use from an org file (for example to
compute table columns), is there a way to save and load the function
from the org file?  I've tried multiline [[elisp: ]] links but they
don't work well, maybe something like...

[[eval-source]]
#+BEGIN_SOURCE elisp


#+END_SOURCE

Thanks -- Eric


_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

Reply via email to