From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: "H. Dieter Wilhelm" <dieter@duenenhof-wilhelm.de>
Cc: Jay Belanger <jay.p.belanger@gmail.com>, emacs-orgmode@gnu.org
Subject: Re: Unit conversions and symbolic mathematics with Babel
Date: Wed, 03 Sep 2014 09:19:26 +0200 [thread overview]
Message-ID: <m2y4u1tblt.fsf@polytechnique.org> (raw)
In-Reply-To: <87vbp5urc4.fsf@vsl28t2g.ww011> (H. Dieter Wilhelm's message of "Wed, 03 Sep 2014 08:54:19 +0200")
[-- Attachment #1: Type: text/plain, Size: 1434 bytes --]
On 2014-09-03 08:54, dieter@duenenhof-wilhelm.de (H. Dieter Wilhelm) writes:
> But what is missing is to assign variables within a source block
>
>
> #+BEGIN_SRC calc :var L1 = "5 mm"
> L2 := cvun( L1, m)
> #+END_SRC
>
>
> Unfortunately this is not working. Do you have an idea how to
> implement this?
It seems that you could use block chaining. Here is an extract of some
code I use to compute stats for my book keeping:
#+name: monthly_average
#+begin_src emacs-lisp :var starty=2014 :var startm=3 :var amount=100
(let* ((tm (decode-time))
(cmonth (nth 4 tm))
(cyear (nth 5 tm))
(nbmonths (+ (* 12 (- cyear starty)) (- cmonth startm))))
(calc-eval "round($ / $$, 2)" nil amount nbmonths))
#+end_src
#+name: ledger_average
#+begin_src emacs-lisp :var b="Quotidien" :var sy=2014 :var sm=3 :var sd="2014-03-01" :var p="Expenses:"
(let* ((per (format "from %d-%d-01 to this month" sy sm))
(a (org-sbe call_ledger (bucket (eval b)) (prefix (eval p)) (period (eval per)))))
(org-sbe monthly_average (amount (eval a)) (starty (eval sy)) (startm (eval sm))))
#+end_src
The last line of the second block calls the first block to do its
computation. The first block does not have to be in emacs-lisp, but
I don't know calc well enough to do it directly in calc.
Best,
Alan
--
OpenPGP Key ID : 040D0A3B4ED2E5C7
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 494 bytes --]
next prev parent reply other threads:[~2014-09-03 7:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-03 6:54 Unit conversions and symbolic mathematics with Babel H. Dieter Wilhelm
2014-09-03 7:19 ` Alan Schmitt [this message]
2014-09-03 7:32 ` Eric Abrahamsen
2014-09-03 13:18 ` Brett Viren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2y4u1tblt.fsf@polytechnique.org \
--to=alan.schmitt@polytechnique.org \
--cc=dieter@duenenhof-wilhelm.de \
--cc=emacs-orgmode@gnu.org \
--cc=jay.p.belanger@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).