emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] very long table calc expressions ?


From: Thierry Banel
Subject: Re: [O] very long table calc expressions ?
Date: Fri, 22 Jun 2018 19:22:33 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 22/06/2018 18:48, Nick Dokos wrote:
> Uwe Brauer <address@hidden> writes:
>
>> Hi Jonathan
>>
>>    > Hi Uwe,
>>    > On Fri, Jun 22, 2018 at 10:16 AM, Uwe Brauer <address@hidden> wrote:
>>
>>    > (::)
>>    > not just a single.  Brent's example has it with double while yours only
>>    > shows
>>    > it with a single one.
>>
>> Right, thanks for clarifying that. My original example had various :: and
>> indeed there Bernt's advice helped. 
>>
>> Meanwhile Thierry posted a more sophisticated example containing only
>> simple :
>> (which   does not work with ::) and that example cannot be dealt with via 
>> C-c '.
>>
>> @Thierry: that is correct?
>>
> The double colons separate different formulas. The single colons in Thierry's
> formula are  part of the syntax of a conditional expression, i.e. they are 
> part
> of a *single* (long) formula. So yes, that cannot be dealt with via C-c '.
>
A utility lisp function can enhance readability:

#+begin_src elisp
  (defun test-to-interval (x)
    (let ((n (string-to-number x)))
      (cond
       ((equal x "")              "NP")
       ((and (<= 0 n) (<= n 4.9)) "SS")
       ((and (<= 5 n) (<= n 6.9)) "AP")
       ((and (<= 7 n) (<= n 8.9)) "NT")
       ((and (<= 9 n) (<= n 10 )) "SB")
       (t                         "other"))))
#+end_src

#+TBLNAME: raw-data
| Test | Interval |
|------+----------|
|    0 | SS       |
|    1 | SS       |
|    2 | SS       |
|    3 | SS       |
|    4 | SS       |
|    5 | AP       |
|    6 | AP       |
|    7 | NT       |
|    8 | NT       |
|    9 | SB       |
|      | NP       |
|      | NP       |
|      | NP       |
#+TBLFM: $2='(test-to-interval $1)







reply via email to

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