emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Can this table formula be done more efficient


From: Eric Schulte
Subject: Re: [O] Can this table formula be done more efficient
Date: Sun, 08 Jun 2014 09:07:16 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

Nick Dokos <address@hidden> writes:

> Cecil Westerhof <address@hidden> writes:
>
>> At the moment I am using the following formula:
>>     #+TBLFM: @<<$4..@>>$4 = $2 - $3 :: @>$2=vsum(@<<$2..@>>$2) ::
>> @>$3=vsum(@<<$3..@>>$3) :: @>$4=vsum(@<<$4..@>>$4)
>>
>> This does what I want, but there are two things that could be improved.
>>
>> - The second, third and fourth formula do exactly the same, only on
>> different columns. Could this be rewritten to one formula?
>>
>
> --8<---------------cut here---------------start------------->8---
> #+TBLFM: @<<$4..@>>$4 = $2 - $3 :: @>$2..$4=vsum(@<<$0..@>>$0)
> --8<---------------cut here---------------end--------------->8---
>
> See (info "(org) References")
>
>> - The line becomes long and hard to evaluate for a person. Is there
>> a possibility to put the formulas below each-other?
>>
>
> I don't believe so but my belief may be out of date. It has been
> discussed before: check the list archives.

Sort of but not really.  See "Using multiple #+TBLFM lines" in the
manual.

,----
| Using multiple #+TBLFM lines
| ............................
| 
| You may apply the formula temporarily.  This is useful when you switch
| the formula.  Place multiple ‘#+TBLFM’ lines right after the table, and
| then press ‘C-c C-c’ on the formula to apply.  Here is an example:
| 
|      | x | y |
|      |---+---|
|      | 1 |   |
|      | 2 |   |
|      #+TBLFM: $2=$1*1
|      #+TBLFM: $2=$1*2
| 
| Pressing ‘C-c C-c’ in the line of ‘#+TBLFM: $2=$1*2’ yields:
| 
|      | x | y |
|      |---+---|
|      | 1 | 2 |
|      | 2 | 4 |
|      #+TBLFM: $2=$1*1
|      #+TBLFM: $2=$1*2
| 
| Note: If you recalculate this table (with ‘C-u C-c *’, for example), you
| will get the following result of applying only the first ‘#+TBLFM’ line.
| 
|      | x | y |
|      |---+---|
|      | 1 | 1 |
|      | 2 | 2 |
|      #+TBLFM: $2=$1*1
|      #+TBLFM: $2=$1*2
`----


-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D (see https://u.fsf.org/yw)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]