[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Rounding percentages... was setq-default
From: |
Jean Louis |
Subject: |
Rounding percentages... was setq-default |
Date: |
Tue, 20 Apr 2021 08:44:28 +0300 |
User-agent: |
Mutt/2.0.6 (2021-03-06) |
* Emanuel Berg via Users list for the GNU Emacs text editor
<help-gnu-emacs@gnu.org> [2021-04-19 20:28]> > Let us say there are 2 buffers,
you wish to mark 3 people
> > in the list in one buffer and 4 people in the list in other
> > buffer, but you don't want to mix them. Their marks go into
> > individual or buffer local variables that are named same
> > but are different from buffer to buffer. [...]
>
> This is what you do for a living, move people
> between buffers?
I also may move goods from buffer to buffer.
> But I also have lists of people, .mailrc is one, the other is
> a NOC list (Non-Official Cover list) of people climbing in
> our tree house [1] - without here being tricked into letting
> the authorities score an easy win by me disclosing the list,
> let me say that it is a possibility that we currently have 57
> people climbing, 52% from se, 16 nationalities, 54% females.
(defun pct-of-number-in-total (number total)
"Return the percentage that NUMBER represents in a TOTAL."
(/ number total 0.01))
(defun pct-of-number-in-total-1 (number total)
"Return the percentage that NUMBER represents in a TOTAL."
(let* ((number (+ number 0.0))
(total (+ total 0.0))
(percent (/ total 100.0))
(percentage (/ number percent 100)))
percentage))
(defun pct-list (list)
"Return list that representes percentages of values in a given LIST."
(let* ((total (apply '+ list)))
(mapcar (lambda (item) (pct-of-number-in-total item total)) list)))
(pct-list '(31 26)) ⇒ (54.385964912280706 45.614035087719294)
I am not sure how do you get 54% females, maybe one of them is round?
(pct-list '(30 27)) ⇒ (52.63157894736842 47.368421052631575)
The round one must be coming from Sweden according to above math.
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
Sign an open letter in support of Richard M. Stallman
https://stallmansupport.org/
https://rms-support-letter.github.io/
- Re: don't understand setq-default, (continued)
- Re: don't understand setq-default, Jean Louis, 2021/04/18
- Re: don't understand setq-default, Emanuel Berg, 2021/04/18
- Re: don't understand setq-default, Jean Louis, 2021/04/19
- Re: don't understand setq-default, Emanuel Berg, 2021/04/19
- Re: don't understand setq-default, Emanuel Berg, 2021/04/18
- Re: don't understand setq-default, Jean Louis, 2021/04/19
- Re: don't understand setq-default, Emanuel Berg, 2021/04/19
- Rounding percentages... was setq-default,
Jean Louis <=
- Re: Rounding percentages... was setq-default, Emanuel Berg, 2021/04/29
Re: don't understand setq-default, Jean Louis, 2021/04/18