type/with_unit - Maple Programming Help

Online Help

All Products    Maple    MapleSim


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

type/with_unit

check for a Maple unit

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

type(expr, with_unit(typ, coeff, unit))

Parameters

expr

-

expression

typ

-

(optional) Maple type

coeff, unit

-

(optional) names

Description

• 

A Maple expression is with a unit if it is the function Units[Unit] applied to some arguments, a rational power of such an expression, or a product of such expressions, potentially also with another Maple expression.

• 

The function call type(expr, with_unit) returns true if expr is of the form described above. Otherwise, false is returned.

• 

In the remainder of this help page, we will refer to the product of the powers of the Units[Unit] function as the unit of the expression, and the product of the remaining factors (if any) as the multiplier. If there are no other factors, the multiplier is 1.

• 

If an optional type typ is given and expr is of the form described above, it additionally checks that the multiplier is of the type typ. The function returns true if this additional condition is satisfied. Otherwise, false is returned.

• 

If optional arguments coeff and unit are given and type(expr, with_unit(typ)) returns true, then the unit of expr is assigned to unit and the multiplier is assigned to coeff.

Examples

Notes: 

– 

To enter a unit in 2-D Math input, select the unit from the appropriate Units palette. If the unit you want is not there, select unit and then enter the unit.

– 

In Maple 2015 and later versions, the double brackets around a unit are not displayed unless you are editing the unit.

withUnits[Standard]:

3m

3m

(1)

type3m,with_unit

true

(2)

type3m,with_unitinteger

true

(3)

type3x2m,with_unitinteger,'a','b'

false

(4)

a,b

a,b

(5)

type3x2m,with_unitanything,'a','b'

true

(6)

a,b

3x2,m

(7)

type2m,with_unitinteger,'a','b'

true

(8)

a,b

2,m

(9)

withUnits[Natural]:

3m

3m

(10)

type3m,with_unit

true

(11)

type3m,with_unitinteger

true

(12)

type3x2m,with_unitinteger,'a','b'

false

(13)

a,b

2,m

(14)

type3x2m,with_unitanything,'a','b'

true

(15)

a,b

3x2,m

(16)

type2m,with_unitinteger,'a','b'

true

(17)

a,b

2,m

(18)

See Also

type

type/unit

Units

Units/Index

Units/Natural

Units/Standard

verify/structured