From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id 4EdRGKR7VmNzigAAbAwnHQ (envelope-from ) for ; Mon, 24 Oct 2022 13:48:52 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id KJEuGKR7VmNXqgAAauVa8A (envelope-from ) for ; Mon, 24 Oct 2022 13:48:52 +0200 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 26F13CC0A for ; Mon, 24 Oct 2022 13:48:52 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omvsM-0000aY-Cw; Mon, 24 Oct 2022 07:44:14 -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 1omvsK-0000aK-Cg for emacs-orgmode@gnu.org; Mon, 24 Oct 2022 07:44:12 -0400 Received: from mailer-211-159.hitrost.net ([91.185.211.159]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omvsG-00059Y-Ih for emacs-orgmode@gnu.org; Mon, 24 Oct 2022 07:44:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=christianmoe.com; s=x; h=Content-Type:MIME-Version:Message-ID:Date: In-reply-to:Subject:Cc:To:From:References:Sender:Reply-To: 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=0mv/cOophZ4Nv/C/wQJThDipIr4gZr9CTsgMZWnDOjw=; b=Ym906N84Y1mLpT1XcJDjSJo+CE nShWpckrgn5Q6oTSE/j92gocvlasnS/O37yF6+4wDQQKevhzRNjF+tHoI3csKuv9Xvcg00fEL2mUs AcZUbT9uDmWnHRDicGPv6pQlfSh8zKIRT5VQYwLpRvpncE5z5BS/+yaP6kULsUtrwtE7og1bWyj6y 4qjo+4+3d22vmdUt8qW2gCTCjzZFaGVrl2tMCuGNMWTFNkgoYpTpscoht5FuZMrLTD1Pd7CV8qm6I zonzdje3e1PzJdy+wPoMhwCJmZpMz+feHOUbTA+/zu+Yj3pNej2qkNBY0RKXChqGuZdeCj5BRpJEh LGzVkhjQ==; Received: from 84-20-244-215.dynamic.telemach.net ([84.20.244.215] helo=Tauriel) by b1.hitrost.net with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1omvs2-001NUE-2c; Mon, 24 Oct 2022 13:43:54 +0200 References: <87r0yxr6wm.fsf@ucl.ac.uk> <87bkq1pogu.fsf@localhost> <87sfjd35xh.fsf@ucl.ac.uk> User-agent: mu4e 1.2.0; emacs 27.2 From: Christian Moe To: emacs-orgmode@gnu.org Cc: Ihor Radchenko , Ypo Subject: Re: LIterate programming with calc (help) In-reply-to: <87sfjd35xh.fsf@ucl.ac.uk> Date: Mon, 24 Oct 2022 13:43:54 +0200 Message-ID: <87zgdlwio5.fsf@christianmoe.com> MIME-Version: 1.0 Content-Type: text/plain X-GeoIP: Country [IP], SI [84.20.244.215] X-Antivirus-Scanner: Clean mail though you should still use an Antivirus X-Authenticated-Id: mail@christianmoe.com Received-SPF: pass client-ip=91.185.211.159; envelope-from=mail@christianmoe.com; helo=mailer-211-159.hitrost.net X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Sender: "Emacs-orgmode" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666612132; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=0mv/cOophZ4Nv/C/wQJThDipIr4gZr9CTsgMZWnDOjw=; b=u+98tU15tEnior9TPjTGL+RriuLq9bL3e4fwZ4rDTjTlHp1ZK9EYwH7N7OzCusGmJUHCSW OdxagEsiftktMCsQ0qf+SbJiX4iiMwvaB8rGzooN52sqgNL5uoK9s5NJpzlK0CIkV+bqdl svpujuBAANj5YF/dK1IP3ENpSuc+gtG05PEwIb0O2evcL81vd0I/FIUu/4tbkjJiQLZerS dz2fWumP6RZTvYXys5ENIegn/9BeGFQIA0em7as/AK9lyWJ9OTHKntZAhjib41me9zBWdE A69HaUKwmSFJE9rj4aw78BzyQp/yYueNtf/YNeqs7XXYglPgoepR+ihMFhSt7A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666612132; a=rsa-sha256; cv=none; b=dhPtvbuA1EAZgQ/vn2uU6G4TsC1Tstn2OzQaUHEQoGQaw7oZ77ZOb05v12rWLlHt4MH09t jCjBoZX41mQfmanW+pTpCpA9slNqzMtnmHGHywWB+BYOxko7Fs2ZV0/JJ68dyyqNSFWALD mFyNyIjB0gnS8UiZCV9u0wfXn0CwkChd1eFi9yFwUFRamL6C+8TnWcVCMmHGwYBqBopcFN Zz07WNF85eDeHWEIdK8IBlDCyIuq1xayaZQYBzB/L9bvc13i/snobFR+SpITtoY07n4d0W fFUsLg5jlJwRvaitCWC3dTqSZkTtNT48wPTEudni83iiCOoKLiEs+zwX6/8U3w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=christianmoe.com header.s=x header.b=Ym906N84; dmarc=none; 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" X-Migadu-Spam-Score: -1.20 Authentication-Results: aspmx1.migadu.com; dkim=none ("invalid DKIM record") header.d=christianmoe.com header.s=x header.b=Ym906N84; dmarc=none; 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" X-Migadu-Queue-Id: 26F13CC0A X-Spam-Score: -1.20 X-Migadu-Scanner: scn0.migadu.com X-TUID: ZUgkzrD2vVvu Fraga, Eric writes: > On Monday, 24 Oct 2022 at 09:20, Ihor Radchenko wrote: >> I vaguely recall that storing variables in calc is something like >> variable := assignment (which is actually rewrite rule, but that's how >> 13.1 Storing Variables section of the calc manual explains variable >> assignments). > > That is true for embedded calc (which I use all the time) but I cannot > seem to get this to work for src blocks: Same: it requires using the `s s' (calc-store) command, though (which can also be done without the := assignment operator), and I've searched the manual without spotting a way to do that with algebraic entry and hence in a src block, as there doesn't seem to be any corresponding command. I hope there is a way, though! As an unsatisfying workaround, one could use :var header arguments; they work up to a point, but not with units, as Ypo wants to use (and which are are a really cool thing about Calc). Once one's using variables, it will probably be necessary to wrap the final calculation in evalv() to get a numeric value as output instead of a formula with the variable names in it. Another obstacle to what Ypo is trying to do is the attempt to use the $ sign for the currency unit. Calc does not have pre-defined currency units, and $ is taken - it refers to the last value on stack. I tend to use 'USD'. So a partial, if pointless, way to do this would be to first store the variables with the calculator: ' 300 m s s a # store a = 300 m ' 300 m s s b # store b = 300 m ' 1 USD/m^2 s s cost # store cost = (1) usd/m^2 ' a*b s s Area # store Area = a*b (*not* 90000 m^2) Then the last step could be done in a src block: #+begin_src calc evalv(Area * cost) #+end_src #+RESULTS: : 90000 USD (Another cool bit: If you change the value of a or b and rerun the src block, the result will change, since what was stored in Area was the product of the variables, not the product of their values.) Yours, Christian