[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Multiple calc commands with orgbabel
From: |
Tom Gillespie |
Subject: |
Re: Multiple calc commands with orgbabel |
Date: |
Wed, 5 May 2021 09:19:51 -0700 |
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 <pietru@caramail.com> 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" <moptop99@gmail.com>
> To: "Org Mode List" <emacs-orgmode@gnu.org>
> 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 <e.fraga@ucl.ac.uk> 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
>>
- Multiple calc commands with orgbabel, pietru, 2021/05/05
- Re: Multiple calc commands with orgbabel, Eric S Fraga, 2021/05/05
- Re: Multiple calc commands with orgbabel, Matt Price, 2021/05/05
- Re: Multiple calc commands with orgbabel, Eric S Fraga, 2021/05/05
- Re: Multiple calc commands with orgbabel, Tom Gillespie, 2021/05/05
- Re: Multiple calc commands with orgbabel, Bastien, 2021/05/06
- Re: Multiple calc commands with orgbabel, Tom Gillespie, 2021/05/06
- Re: Multiple calc commands with orgbabel, Bastien, 2021/05/07
- Re: Multiple calc commands with orgbabel, Tom Gillespie, 2021/05/07
- Re: Multiple calc commands with orgbabel, Bastien, 2021/05/07
- Re: Multiple calc commands with orgbabel, pietru, 2021/05/05
- ob-fortran behaviour, Christopher Dimech, 2021/05/05
- Re: ob-fortran behaviour, Christopher Dimech, 2021/05/05