[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Orgmode] Spreadsheet and weighted means
From: |
Nicolas Goaziou |
Subject: |
Re: [Orgmode] Spreadsheet and weighted means |
Date: |
Wed, 01 Oct 2008 18:46:02 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
Carsten Dominik <address@hidden> writes:
Hello,
> Hi Nicolas, there s no builtin way to deal with this, in particular
> with the fact that you want to treat empty fields as non-existing, and
> therefore also to ignore the corresponding weight.
>
> You cou write a Lisp function to do this, though:
>
> (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)))))
> (/ vsum wsum)))
Well, thank you very much: it does the job.
I don't want to be picky but I'll investigate on a way to have an empty
string instead of a sorry 0 whenever a student hasn't sat for any exam.
Finally, I wondered if it would be useful to make it built-in as
weighted means are somewhat popular in education.
Anyway, thanks again.
--
Nicolas Goaziou