0

TL;DR: How do you send a list of elements from a table, including blank cells, to an elisp function?

I have the table below with points on exam questions in columns 2-4. The second row contains the maximum number of points for each question. The student rows contain the actual points received. I want to compute the maximum possible sum for a student, to be updated while I grade the questions.

I have written an elisp function that takes two lists as arguments and does the necessary computations. However, the standard selection argument ignores blank elements. In the function call below, the function will receive the (fontified) lists '("3" "4") '("6" "4" "6") and '("6" "2") '("6" "4" "6"), respectively. I need a selection where each blank element is kept as, e.g., fontified "". Is that possible?

Have tried google and the org manual to no avail.

#+NAME: PTS
|           | Q1| Q2| Q3|     | Max |
|-----------+---+---+---+-----+-----|
|           | 6 | 4 | 6 | Sum | Sum |
|-----------+---+---+---+-----+-----|
| Student 1 | 3 | 4 |   |   7 |  13 |
| Student 2 | 6 |   | 2 |   8 |  12 |
#+TBLFM: @3$6..@>$6='(sum-with-defaults '(@0$2..@0$4) '(@2$2..@2$4)))
1

[Untested]

The documentation[1] says that an E mode string after the formula should keep empty fields as empty strings in a range (there is also an N mode string which forces all fields to be numbers - if the numeric conversion fails, the field is treated as the number 0):

#+NAME: PTS
|           | Q1| Q2| Q3|     | Max |
|-----------+---+---+---+-----+-----|
|           | 6 | 4 | 6 | Sum | Sum |
|-----------+---+---+---+-----+-----|
| Student 1 | 3 | 4 |   |   7 |  13 |
| Student 2 | 6 |   | 2 |   8 |  12 |
#+TBLFM: @3$6..@>$6='(sum-with-defaults '(@0$2..@0$4) '(@2$2..@2$4)));E

[1] The section after the one I linked talks about "Formula syntax for Lisp" and mentions that modes can be used for such formulas as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.