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.

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

Link to this function

convert(tu1, tu2)

Convert units, for example iex> import Exun.Unit iex> "120[Km/h]" |> convert("m/s") "33.333333333333336[m/s]"

Link to this function

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]"

Link to this function

exps_tostr(exps)

Link to this function

factorize(e1, e2)

Link to this function

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]"
Link to this function

get_def(name, pcontext)

Transform a name into a unit, looking at fundamentals, conversions, context and prefixes, in that search order.

Link to this function

sum(op, arg1, arg2, pcontext)

Sum of two units

Convert unit to International System args: unit

Link to this function

to_si(arg, pcontext, curr_exp, exps)

Convert unit to International System args: {coef, ast}, parsed_context, current_exponent, exponents returns: {newcoef, exponents}