type/syntactically_valid_compound_unit - Maple Programming Help

Home : Support : Online Help : Programming : Data Types : Type Checking : Types : type/syntactically_valid_compound_unit

type/syntactically_valid_compound_unit

check syntactically for a valid compound unit

 Calling Sequence type(expr, syntactically_valid_compound_unit)

Parameters

 expr - expression

Description

 • A Maple expression is syntactically valid as a compound unit if it is a product of rational powers of syntactically valid unit names, possibly further multiplied by a constant.
 • The type(expr, syntactically_valid_compound_unit) function returns true if expr has the form of a syntactically valid compound unit. Otherwise, false is returned.
 • This type exists mostly for use by the Units package internally; if you are considering using this in your program to test something related to user functionality, then it is almost certainly not what you want. Consider instead using the type with_unit to find expressions with units attached, or specfunc(Units:-Unit) to find Unit function calls.

Examples

 > $\mathrm{type}\left({\mathrm{meter}}^{2},\mathrm{syntactically_valid_compound_unit}\right)$
 ${\mathrm{true}}$ (1)
 > $\mathrm{type}\left(\frac{L}{100\mathrm{km}},\mathrm{syntactically_valid_compound_unit}\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{type}\left(\frac{\mathrm{kg}{m}^{2}}{{s}^{3}},\mathrm{syntactically_valid_compound_unit}\right)$
 ${\mathrm{true}}$ (3)
 > $\mathrm{type}\left(\mathrm{newton}\mathrm{meter}\left(\mathrm{radius}\right),\mathrm{syntactically_valid_compound_unit}\right)$
 ${\mathrm{true}}$ (4)

The type tests only whether expr would be valid as a compound unit, not whether it is actually a unit that Maple knows about. For example, not_an_actual_unit would be a valid unit name (and by extension a valid compound unit), so this type returns true. However, it is not an actual unit that is defined in the Maple library.

 > $\mathrm{type}\left(\mathrm{not_an_actual_unit},\mathrm{syntactically_valid_compound_unit}\right)$
 ${\mathrm{true}}$ (5)

The expression for a distance of 2 meters plus 3 feet would not be valid as a compound unit.

 > $\mathrm{distance}≔2\mathrm{Unit}\left(m\right)+3\mathrm{Unit}\left(\mathrm{ft}\right)$
 ${\mathrm{distance}}{≔}{2}{}⟦{m}⟧{+}{3}{}⟦{\mathrm{ft}}⟧$ (6)
 > $\mathrm{type}\left(\mathrm{distance},\mathrm{syntactically_valid_compound_unit}\right)$
 ${\mathrm{false}}$ (7)