From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 6HVcLP7QkmB13wAAgWs5BA (envelope-from ) for ; Wed, 05 May 2021 19:08:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 2JbrJ/7QkmD/HAAAbx9fmQ (envelope-from ) for ; Wed, 05 May 2021 17:08:14 +0000 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 F2465CB99 for ; Wed, 5 May 2021 19:08:13 +0200 (CEST) Received: from localhost ([::1]:49886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1leL0O-0003SD-Pc for larch@yhetil.org; Wed, 05 May 2021 13:08:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1leKFv-0004TG-D6 for emacs-orgmode@gnu.org; Wed, 05 May 2021 12:20:17 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:46624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1leKFs-0001H2-8j for emacs-orgmode@gnu.org; Wed, 05 May 2021 12:20:10 -0400 Received: by mail-wm1-x32f.google.com with SMTP id k4-20020a7bc4040000b02901331d89fb83so1469621wmi.5 for ; Wed, 05 May 2021 09:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=i+5zi0GJWx7J/LNRj54Sqt4A6fP0aBjrkyEijuGiQT8=; b=WNmGYB3btPDtSKaJpd9OAxcPwvzTYyZE7wvUB0LBKjL3DHi+vrFIYa2EBmjXwPGDQm f59rPaGfYnnw2qUYmDxcZAGDJHh7Jv6PtJ9fLrRGe1IGm+3ZHmgC7GrThoQYQ0QWhp0V B+9oZoSQcl3Ww90ST9en44C0W6X1rAGEfriW+vUZv1hBpH+4W8FRM6wMJx9aHaryCOeo fAuPn9HMoG1NKFvqwo/2JRWHLanHVdmpGnVed2fv5sPD//y9MTxQB0KDfukjo0uQxOo4 EdstV8+RREa5nlSwDXCqV39vngvWGLX25lcuYdyv6Rqzw72BydDai4eSdfjOfIQ0niEN hgfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=i+5zi0GJWx7J/LNRj54Sqt4A6fP0aBjrkyEijuGiQT8=; b=tH41sB4DkUtF2FpA5RezVRlIskkr7yCN0J54j48qJlfdeHfcS448fCnDBlossZvtT6 Kd+n6sfWndAiXOiaGxZLIbX4LDTVFEtUVAgP87x+1XKkDSrNFmUbeKTgh1FPhdp3uUqq ljlrMpBjbXAq4RRkaaWlXjqOBlar94B7s+NmMbfseltDmFQS8ufbfPbvY6rA1mlHjRvM z2PuscCqc2WQDFcoaH+nAvq43s3WPd6MzWG4p9v/vpGNV7mbumJDDIcQ8KET1SP7GhGX ClLydFuDpj+sW+O28RY0z28jkwDAeTTiRM6CeMLltU5baXJ9utrmJZ5Pc648cl0eZqvq hYuA== X-Gm-Message-State: AOAM531LNc0H/oEJqWUJQ4iBiFKhVzBdIqskGxH2c0ZYtbJ3NMroMn43 dmylg3Z/CZt5rIaD8qtz0McGUXNwCXsVa9Fik3Y= X-Google-Smtp-Source: ABdhPJz6focrWTUWGe7G2K94xooB7q1mE2ImGUY5y0lXsDsl5k62l6ZQAEaUYg9/i01Z0J4vmiucKdtr4bqNS1MyoFw= X-Received: by 2002:a1c:c911:: with SMTP id f17mr34675051wmb.45.1620231603248; Wed, 05 May 2021 09:20:03 -0700 (PDT) MIME-Version: 1.0 References: <871ral7kq8.fsf@ucl.ac.uk> In-Reply-To: From: Tom Gillespie Date: Wed, 5 May 2021 09:19:51 -0700 Message-ID: Subject: Re: Multiple calc commands with orgbabel To: pietru@caramail.com Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=tgbugs@gmail.com; helo=mail-wm1-x32f.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.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, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Org Mode List Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1620234494; 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=i+5zi0GJWx7J/LNRj54Sqt4A6fP0aBjrkyEijuGiQT8=; b=UYgNwMA5pPi4GfmFbp4Xum/VKgDIqk4jyj4QHXEWJi9lZrbJJvYhVh/O33d4+tA1fKvL3h CiPyGKfaS4cHK5b9qeCsVs1ZlqNp1B2tWze6XdOd1j+FCHKvAADHV1ayCpS5kLvCThy3ae 3xpcWeA4jJqNtcvcktqmTBPYDZ3JwtUc7CffOBAne4cDHxa4pu29f2Wnk+ptNwWfCL6k5Q edBKJK2xXTJuDUNKIPDExJ85SI06SqnUCwpQkZjwZiwB8e5/nv5MH9tLOUhnrPKW4S6NSa bY0C8zA4wAsEkqYAw+zUBFNiHAQAyTcoIBqTPrhN84p/XNr6kcJlLHBQdhxbYQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1620234494; a=rsa-sha256; cv=none; b=mO1RQ+nnRyDCAbC3RZ71S+FtE1pNNJVIxVZ/GjiuMTKA+9RFeV+UjIWW4+D4eBMnTuEKCh z1y5runq/A+VSbjH4z6xFjfxbaWF/1GNsOUf6RYZwz28pgRm4x16E5cAknOjNiFo18ZsPx dLDT7DxqwXUs0wIKf0VFO+XXyiHIH0ZnhgfOfYk37dfyb10NQ/VFiXs0sk017st7JC0Vdd nUySE0F53iVMqT9tqLhRtSlbptULMcT4g1WSnQ8UQTEuYMZjuOCmDQe60RnXsY17i65TlD +cz0IAhxnKhyWrnu/Cblkgc5Rj0WEhJTCT/iPnt5TSwvVsZexneMWqgFOR2DHg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=WNmGYB3b; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.37 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=WNmGYB3b; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: F2465CB99 X-Spam-Score: -1.37 X-Migadu-Scanner: scn0.migadu.com X-TUID: Jjtx9mXmO2Wd Looking at ob-calc there is a call to calc-push-list. Knowing the length of that list (i.e. the number of arguments) it should be possible to inspect calc-stack to retrieve the other values on the stack from the current block. You can see this if you run M-: calc-stack. This would probably need a specialized result type if it were implemented. Best, Tom On Wed, May 5, 2021 at 8:33 AM wrote: > > > Example > > (require 'ob-calc) > (org-babel-do-load-languages > 'org-babel-load-languages > '( (calc . t) ) > > -------- calc.org -------- > > # To execute, place cursor point on a line, then hit "C-c * u" hard with no harm. > > #+name: Simplifying Formulas > #+begin_src calc > > simplify((x + y) (x + y)) => > > simplify(a x^2 b / (c x^3 d)) => > > simplify((4 x + 6) / (8 x)) => > > simplify((1 + 2 i) (3 + 4 i)) => > > simplify(5 + i^2 + i - 8 i) => > > simplify((1, 2) + (3, 4)) => > > simplify((1, 2) (3, 4)) => > > #+end_src > > > > Sent: Thursday, May 06, 2021 at 3:11 AM > From: "Matt Price" > To: "Org Mode List" > Cc: pietru@caramail.com > Subject: Re: Multiple calc commands with orgbabel > Can you explain how you get calc embedded mode working in org? I have never used it and it sounds interesting, but I don't understand what hte delimiters are. > > On Wed, May 5, 2021 at 2:35 AM Eric S Fraga wrote: >> >> On Wednesday, 5 May 2021 at 07:46, pietru@caramail.com wrote: >> > Have been trying to execute multiple calc commands, but when I >> > evaluate the calc expressions, I get just one result. >> >> ob-calc returns the top element of the stack when finished and this will >> be the result of the last operation in the src block. I don't think >> there's any way around this. >> >> I use embedded Calc for this reason. You could rewrite your equations >> as simple lines (separated by empty lines from the surroundings) and >> evaluate each in turn with "C-x * u": >> >> fsolve(x 2 + x = 4, x) => x = 1.33333333333 >> >> fsolve([x + y = a, x - y = b], [x, y]) => [x = a + (b - a) / 2, y = (a - b) / 2] >> >> I added the "=>" at the end of each expression so that the result is >> shown to the right instead of replacing the expression itself (default >> embedded Calc behaviour). >> >> -- >> : Eric S Fraga via Emacs 28.0.50, Org release_9.4.5-395-g82fbdd >>