Org tables are great! But sometimes, for non-trivial cases, the formulas get a little unwieldy. E.g.:
#+TBLFM: @III+1$3..@IIII-1$>='(let ((l (-non-nil (mapcar* (lambda (w v) (when (equal w $2) (string-to-number v))) (list @II+1$2..@III-1$2) (list @II+1..@III-1))))) (/ (-sum l) (float (length l))));E%.1f
(There might be a denser Calc syntax for the above, but that's beside the point.)
Editing it as it is all cramped in one line is not great. There is also no way to document the formula or its parts.
Is there a way to split the formula into multiple lines?
If not, is there a way to define an Emacs Lisp function within the same file, so that it is evaluated automatically when the .org
file is opened?