Heiko Schmidt <heiko.schm...@webbedtables.de> writes: > - problem: When evaluating the calc snippets the top of stack element > is dropped. Because every "begin/end_src calc" block drops the top > of stack, one can't reuse the result in following blocks.
> Number of cars (PKW) in germany: > > #+begin_src calc :exports both > 45e6 > #+end_src > > > #+RESULTS: > : 45000000. > > Yearly mileage in [km/y] > > #+begin_src calc :exports both > 15000 > #+end_src > > > #+RESULTS: > : 15000 > > Calculate amount of complete km per year > > #+begin_src calc :exports both > '* > #+end_src > > > #+RESULTS: > : 675000000000. > - problem: babel removes the resulting top stack element from the > stack > > - tried solution: duplicate the last stack-element on evaluation with > "' " (emulate <space> press to duplicate the top element of the > stack in calc) > ** hope for a solution or work around from the community > > - preferred: Is there a way to leave the top of stack from one snippet > to the next (which I don't know)? > - alternative: Is there a way to duplicate the top of stack element > between begin/end_src calc blocks? > - any advice is appreciated. Okay. I take here the "any advice is appreciated" part. AFAICS at the org babel calc evaluation the last value of the calc stack gets dropped. So your workaround is okay, I think. You can just write any dummy element at the bottom of each block e.g. just 0. No need of duplication. Looks a bit hackish to me but so what? Another approach could be "noweb". Example (you would just evaluate the block at the bottom): --8<---------------cut here---------------start------------->8--- Number of cars (PKW) in germany: #+name: numcars #+begin_src calc :exports both 45e6 #+end_src Yearly mileage in [km/y] #+name: mileage #+begin_src calc :exports both 15000 #+end_src Calculate amount of complete km per year #+begin_src calc :noweb yes <<numcars>> <<mileage>> '* #+end_src --8<---------------cut here---------------end--------------->8--- HTH, -- Marco