From mboxrd@z Thu Jan 1 00:00:00 1970 From: Manuel Schneckenreither Subject: Table formula references Date: Thu, 30 Mar 2017 10:37:50 +0200 Message-ID: <87a883gnxd.fsf@uibk.ac.at> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41460) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctVbP-0000fD-KT for emacs-orgmode@gnu.org; Thu, 30 Mar 2017 04:38:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctVbM-0004z7-FT for emacs-orgmode@gnu.org; Thu, 30 Mar 2017 04:38:43 -0400 Received: from smtp.uibk.ac.at ([138.232.1.140]:33926) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ctVbM-0004ul-5L for emacs-orgmode@gnu.org; Thu, 30 Mar 2017 04:38:40 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Hi, I'd like to use following formula on like this: | t | y_t | y_{t+1} | |---+-----+---------| | 1 | 115 | | | 2 | 121 | | | 3 | 118 | | | 4 | 127 | | $4 = \sum_{\tau=0}^{@#-2}{0.9^{\tau} * y_{@#-2-\tau}} So that's a simple sum, which just iterates over the values and uses the index for power and to get the value of y_{4-\tau}. So @5$3 should be 0.9^0*127 + 0.9^1*118 + 0.9^2*121 + 0.9^3*115. Shouldn't be too hard I though, but I couldn't figure it out how to implement it using org-spreadsheets. As I need the index I tried using subscr with no success. I can obviously generate the list of rows used for the calculation using @2$1..@2$#. However, as soon as I use an elsip function in the formula I struggle with the representation of the list: #+TBLFM: $3='(mapcar '1+ (@2$1..@2$#)) shows following debug output: Substitution history of formula Orig: '(mapcar '1+ (@2$1..@2$3)) $xyz-> '(mapcar '1+ (@2$1..@2$3)) @r$c-> '(mapcar '1+ (#("1" 0 1 (fontified t line-prefix #("******* " 0 7 (face org-indent)) wrap-prefix #("******* " 0 8 (face org-indent)) face org-table)) #("115" 0 3 (fontified t line-prefix #("******* " 0 7 (face org-indent)) wrap-prefix #("******* " 0 8 (face org-indent)) face org-table)))) $1-> '(mapcar '1+ (#("1" 0 1 (fontified t line-prefix #("******* " 0 7 (face org-indent)) wrap-prefix #("******* " 0 8 (face org-indent)) face org-table)) #("115" 0 3 (fontified t line-prefix #("******* " 0 7 (face org-indent)) wrap-prefix #("******* " 0 8 (face org-indent)) face org-table)))) Result: #ERROR Format: NONE Final: #ERROR Is there a simple way to do it? Do I need to go over elsip functions, and if so. How can I properly use a list? I couldn't find a way on the web. Best regards Manuel