define_unit
Look up a unit's definition, kind, dimension, and base value from the GNU units database. Ideal for inspecting what a unit reduces to.
Instructions
Show a single unit/prefix/constant's definition, kind, dimension, and base value (TODO §13).
Looks up one name in the GNU units database and reports exactly what it is and
what it reduces to — the inspect/"define" counterpart to convert. Works for
ordinary units, SI/binary prefixes, physical constants, nonlinear function
units (tempF), and piecewise tables (brwiregauge).
Returns an object with:
name: echoed.kind: "unit" | "primitive" | "prefix" | "function" | "table".definition: the database definition text (source line, leading name token removed). "!" marks a primitive/base unit.dimension: base-unit signature, e.g. "kg m^2 / s^3" for power; "1" when dimensionless. Omitted for hits that do not reduce.base_value: the unit reduced to base units with its coefficient, e.g. "745.699871582 kg m^2 / s^3". Omitted alongsidedimension.function: for nonlinear units only — {signature, input_dimensions, output_dimension} describing the conversion function.
Errors cleanly (isError) when the name is not defined in the database. Example: define_unit("newton") -> {"name":"newton","kind":"unit","definition":"kg m / s^2", "base_value":"1 kg m / s^2","dimension":"kg m / s^2"}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The exact name of a single unit, prefix, physical constant, function, or table to look up — e.g. 'horsepower', 'kilo', 'newton', 'tempF', 'brwiregauge'. This is a definition lookup, not an expression evaluator: pass one database name, not a compound expression like 'kW*hour'. Use find_units first if you are unsure of the exact spelling. |