Exun.Unit (exun v0.1.0)
Link to this section Summary
Functions
Convert units, for example iex> import Exun.Unit iex> "120[Km/h]" |> convert("m/s") "33.333333333333336[m/s]"
Convert first unit to the second unit in convert: u1 = Exun.parse "3[m]" u2 = Exun.parse "1[cm]" Exum.Units.convert(u1,u2,%{}) |> Exum.tostr() "300[cm]"
Factorize unit2 from u1, for example iex(1)> {u1,d} = Exun.parse "1[kmKgA/h^2]", %{}
Transform a name into a unit, looking at fundamentals, conversions, context and prefixes, in that search order.
Sum of two units
Convert unit to International System args: unit
Convert unit to International System args: {coef, ast}, parsed_context, current_exponent, exponents returns: {newcoef, exponents}
Link to this section Functions
convert(tu1, tu2)
Convert units, for example iex> import Exun.Unit iex> "120[Km/h]" |> convert("m/s") "33.333333333333336[m/s]"
convert(arg1, arg2, pcontext)
Convert first unit to the second unit in convert: u1 = Exun.parse "3[m]" u2 = Exun.parse "1[cm]" Exum.Units.convert(u1,u2,%{}) |> Exum.tostr() "300[cm]"
exps_tostr(exps)
factorize(e1, e2)
factorize(arg1, arg2, pcontext)
Factorize unit2 from u1, for example iex(1)> {u1,d} = Exun.parse "1[kmKgA/h^2]", %{}
{u2,d} = Exun.parse "1[N]", %{}
factorized = Exun.Unit.factorize(u1,u2,%{})
Exum.Tree.tostr factorized
"7.566861148315854e-4[N*A]"
get_def(name, pcontext)
Transform a name into a unit, looking at fundamentals, conversions, context and prefixes, in that search order.
help()
sum(op, arg1, arg2, pcontext)
Sum of two units
toSI(arg)
to_si(arg)
Convert unit to International System args: unit
to_si(arg, pcontext, curr_exp, exps)
Convert unit to International System args: {coef, ast}, parsed_context, current_exponent, exponents returns: {newcoef, exponents}