From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id 0LDkOogc/GZLpAAAe85BDQ:P1 (envelope-from ) for ; Tue, 01 Oct 2024 16:00:09 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id 0LDkOogc/GZLpAAAe85BDQ (envelope-from ) for ; Tue, 01 Oct 2024 18:00:09 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tuxteam.de header.s=mail header.b=DO6ue2JB; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1727798408; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=S7JSNJBRshrh+X+5116VRUYBv4L2RlxD26A7/8hKxSo=; b=JtS0IHM2nKOgx/Mks/KSSkIEORXe3+n6HX4xNXIXI/Dey8fLxlW0sLZSop12MKmcYzJ/cM DLG8Ay1JTG1qJ4GuYQmm/6ofXSn7WGGk2+6giBHnpCd8FiCfcJ9sfOpw+TZNTRd19nkdXc M9jSh9bl+srzAZEdovQA7RpZ89hlnQ+dOOGWbUn5+zfCgffhtUd79xc52x2EP+eyUW5zEV xNXyhYlTH/5FwlyG/o7kH5sd33FJfTdxnTcLchLkqrlaqhAJf7+uwlWCtE+CzbOSCVe75X wuLvDEYlkXxImVG7j7HW48M7yvrGIvHd/oQzsGz1VDZe3LLFOzKviXpzXQa06g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=tuxteam.de header.s=mail header.b=DO6ue2JB; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=none ARC-Seal: i=1; s=key1; d=yhetil.org; t=1727798408; a=rsa-sha256; cv=none; b=bgAJzSXexoE5niBa5efH23rG/6fzApEdyXNwz4+iV0YRCBDvC0SugonECxtNU3k7M6mX8h n9ll8LJ2F3s17uMTuOJnuAChYcS54eXDlDhV7zv+l4ZySYG3HOV4MYfY2U0X/o9x97LlNZ p3FbsEd/EmT5cZY028TF0A2+bo4hA+GnXvnJV0wxRdbcpyMlyzyJObt99mo+Pd6tha2Iza pTPnukabFhpPUFzg7YjnYtn4UCi0+N6YX4m441AcDjYFrtDYkGLOS0skUkd/MCkap6RIYb tc+wEgrATdAfL2503Xsh0UROYlgeDPmcMmPgJ8zvj0lm8Qfj0H/t2YNrGUgt/g== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A95AE7CF48 for ; Tue, 01 Oct 2024 18:00:08 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sveQo-00064z-Qc; Tue, 01 Oct 2024 11:04:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sveQG-0005gW-Lu for emacs-orgmode@gnu.org; Tue, 01 Oct 2024 11:04:20 -0400 Received: from mail.tuxteam.de ([5.199.139.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sveQE-0000Sr-FX for emacs-orgmode@gnu.org; Tue, 01 Oct 2024 11:04:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:To:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=S7JSNJBRshrh+X+5116VRUYBv4L2RlxD26A7/8hKxSo=; b=DO6ue2JBXgoGxncgbk4ZyIwFxk f93gDW8D6IcdxMueFUS7QuXLyQA6bUeAcmXf3GXhdjmn3uVAC0UiqzKgnDpRPeOTOaQV27uNTST0v WaYMfqhnl4poviglvqiG0dT2G22gxnHM0dLYjkXp3P1EbyjGFMCFxkxqOTOh1a9LzfnRypC7M9ME5 B0ioBMRJr9kjIlk2k1T89HQ0rm7Uh2MWBWgsisHRePjOtVH7rxi5fWMJ+PCl4ARU2JV1oV/fkKac2 42Ha0P6pI8L/fzz6/Ta95rPtivPm+3Y7DQNKTJxYEebfk4FqIHbOFf9wqkwiwN6yEUJlNtvYpQAqZ BVSQEC9A==; Received: from tomas by mail.tuxteam.de with local (Exim 4.94.2) (envelope-from ) id 1sveQ6-0005nd-IN for emacs-orgmode@gnu.org; Tue, 01 Oct 2024 17:04:10 +0200 Date: Tue, 1 Oct 2024 17:04:10 +0200 To: emacs-orgmode@gnu.org Subject: Re: [Question] Getting cell value and use it in table formula Message-ID: References: <87jzerriv0.fsf@city17.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="J2eTqJ3w8bgsHsYW" Content-Disposition: inline In-Reply-To: <87jzerriv0.fsf@city17.xyz> From: Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -0.37 X-Spam-Score: -0.37 X-Migadu-Queue-Id: A95AE7CF48 X-Migadu-Scanner: mx13.migadu.com X-TUID: ONjz9yjlqV3+ --J2eTqJ3w8bgsHsYW Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Oct 01, 2024 at 04:35:47PM +0200, jman wrote: >=20 > Hello there, >=20 > Let's look at the following table: >=20 > ----------s---------s---------- > | EUR | USD | Exchange rate | > |-----+--------+---------------| > | 10 | 8.97 | 0.897 | > | 15 | 13.455 | | > #+TBLFM: $2=3D'(* (string-to-number $1) (string-to-number (org-table-get = 2 3))) > ----------e---------e---------- >=20 > I've tried a number of things but this is the only incantation is able to > retrieve the value from the cell "@2$3" and use it into the table formula. >=20 > Is there a cleaner way to retrieve a cell value and use it into a table > formula that is a lisp expression? I think it's in the manual (this is Org v9.7): | 3.5.3 Emacs Lisp forms as formulas | ---------------------------------- |=20 | [...] |=20 | By default, references are interpolated as literal Lisp strings: the | field content is replaced in the Lisp form stripped of leading and | trailing white space and surrounded in double-quotes. For example: |=20 | '(concat $1 $2) |=20 | concatenates the content of columns 1 and column 2. |=20 | When the =E2=80=98N=E2=80=99 flag is used, all referenced elements ar= e parsed as | numbers and interpolated as Lisp numbers, without quotes. Fields that | cannot be parsed as numbers are interpolated as zeros. For example: |=20 | '(+ $1 $2);N |=20 | adds columns 1 and 2, equivalent to Calc=E2=80=99s =E2=80=98$1+$2=E2=80= =99. Ranges are inserted | as space-separated fields, so they can be embedded in list or vector | syntax. For example: |=20 | '(apply '+ '($1..$4));N |=20 | computes the sum of columns 1 to 4, like Calc=E2=80=99s =E2=80=98vsum($1= =2E.$4)=E2=80=99. |=20 | When the =E2=80=98L=E2=80=99 flag is used, all fields are interpolate= d literally: the | cell content is replaced in the Lisp form stripped of leading and | trailing white space and without quotes. If a reference is intended to | be interpreted as a string by the Lisp form, the reference operator | itself should be enclosed in double-quotes, like =E2=80=98"$3"=E2=80=99.= The =E2=80=98L=E2=80=99 flag | is useful when strings and numbers are used in the same Lisp form. For | example: |=20 | '(substring "$1" $2 $3);L |=20 | extracts the part of the string in column 1 between the character | positions specified in the integers in column 2 and 3 and it is easier | to read than the equivalent: |=20 | '(substring $1 (string-to-number $2) (string-to-number $3)) > Any suggestion? Thanks. If everything else fails, read the manual ;-) Cheers --=20 t --J2eTqJ3w8bgsHsYW Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZvwPYwAKCRAFyCz1etHa Rt+2AJ9i6ZFHShdRoH0E6d1rjOMDI2Ye7gCfde+SThkJznBvuWGuAFu60MP8IBY= =bwiH -----END PGP SIGNATURE----- --J2eTqJ3w8bgsHsYW--