Hi Rares

On Fri, Jul 8, 2016 at 6:06 AM, Rares Vernica <rvern...@gmail.com> wrote:

> Just to clarify, how would you fix this:
>
> | [2016-07-05 Tue]--[2016-07-06 Wed] | 1d | vsum(d) |
> | [2016-07-06 Wed]--[2016-07-07 Thu] | 1d | 2 d     |
> #+TBLFM: $3=vsum(@1$-1..@0$-1)
>
> Notice the "vsum(d)" instead of the expected "1 d".

Depending on the number of fields in a range Org builds just a value
or a Calc vector of values. This is due to the comparison of r1/r2 and
c1/c2 which are the row and column beginning and end of the range in
the function org-table-get-range:

    (if (and (not corners-only)
             (or (not rangep) (and (= r1 r2) (= c1 c2))))
        ;; Just one field.
        [...]
      ;; A range, return a vector.
      [...])

I can not think of any use case where this should be more useful than
substituting ~(and (= r1 r2) (= c1 c2))~ with ~nil~. But since this
substitution could break existing usage I suggest to add ~vec~ to the
Calc formula:

| [2016-07-05 Tue]--[2016-07-06 Wed] | 1d | d      | [d]      | d   |
| [2016-07-06 Wed]--[2016-07-07 Thu] | 1d | [d, d] | [[d, d]] | 2 d |
#+TBLFM: $3 = @1$2..@0$2 :: $4 = vec(@1$2..@0$2) :: $5 = vsum(vec(@1$2..@0$2))

Michael

Reply via email to