On Sun, Feb 14 2010, Andreas Harder wrote:

> 1) Is it possible to have a comma as decimal separator?
> 
> 2) If you look at the above definition, it works fine with +, –, /, but
> not with *. Is it possible to expand my macro that it will also work with
> a multiplication or even with the last two examples?

Hello Andreas,

Just a quick hack:

\usemodule[calcmath]
\startluacode
sqrt = math.sqrt
pi = math.pi
function my_equation(s, r)
        r = tostring(r)
        tex.print(s:gsub("*", "×") .. "=" .. r:gsub("%.", ","))
end
\stopluacode
\def\calculate#1{\calcmath{\ctxlua{my_equation("#1", #1)}}}
\starttext
\startlines
  \calculate{1+2}
  \calculate{3/2-1}
  \calculate{3*2}
  \calculate{sqrt(2)}
  \calculate{2*pi}
\stoplines
\stoptext

Cheers, Peter

-- 
Contact information: http://pmrb.free.fr/contact/


___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to