"Quantity" (Interpreter Type)
-
See Also
- Quantity
- QuantityVariable
- QuantityVariablePhysicalQuantity
- QuantityVariableCanonicalUnit
- Interpreter
- SemanticImport
- Restricted
- Failure
- UnitConvert
-
- Interpreter Types
- StructuredQuantity
- ComputedQuantity
- PhysicalQuantity
- Age
- Percent
- PercentFraction
- HeuristicPercent
- CurrencyAmount
- CurrencyName
- Number
- ComputedAge
- ComputedPercent
- ComputedPercentFraction
- ComputedHeuristicPercent
- ComputedCurrencyAmount
- SemanticNumber
- ComputedNumber
-
- Text Contents
- Quantity
- Related Guides
-
-
See Also
- Quantity
- QuantityVariable
- QuantityVariablePhysicalQuantity
- QuantityVariableCanonicalUnit
- Interpreter
- SemanticImport
- Restricted
- Failure
- UnitConvert
-
- Interpreter Types
- StructuredQuantity
- ComputedQuantity
- PhysicalQuantity
- Age
- Percent
- PercentFraction
- HeuristicPercent
- CurrencyAmount
- CurrencyName
- Number
- ComputedAge
- ComputedPercent
- ComputedPercentFraction
- ComputedHeuristicPercent
- ComputedCurrencyAmount
- SemanticNumber
- ComputedNumber
-
- Text Contents
- Quantity
- Related Guides
-
See Also
"Quantity" (Interpreter Type)
Natural-language quantity with units.
Details
- "Quantity" can be used in Interpreter and related constructs, including deployed smart form fields.
- Use of "Quantity" requires connectivity to the Wolfram Cloud.
Allowed Forms
- All the natural-language numbers allowed by "SemanticNumber" are supported for the quantity magnitude.
- Examples of unit specifications include:
-
one dime natural-language units 8.9 hours per day/person compound units 30 °C unit abbreviations and symbols 10 miles postfix units $99.99 prefix units
Restriction Specifications
-
Restricted["Quantity",{{choices1,…}}] one among choices Restricted["Quantity",unit] convert to unit Restricted["Quantity",quantityvariable] restrict to units compatible with the physical quantity of quantityvariable Restricted["Quantity",unit,max] a quantity below Quantity[max,unit] Restricted["Quantity",unit,{min,max}] a quantity between Quantity[min,unit] and Quantity[max,unit] Restricted["Quantity",unit,{min,max,s}] a quantity between Quantity[min,unit] and Quantity[max,unit] with step s Restricted["Quantity",quantityvariable,max] a quantity below Quantity[max,unit], with unit the canonical unit of quantityvariable Restricted["Quantity",Automatic,Automatic,n] a quantity whose magnitude has n-digit precision - The bounds min and max and step s can also be expressed as quantities.
- Interpreter[quantityvariable] is equivalent to Interpreter["Quantity",quantityvariable].
Interpretation
- "Quantity" yields a Quantity.
Examples
Basic Examples (3)
Interpret quantities of any kind:
Interpreter["Quantity"]["2 pounds"]Interpreter["Quantity"]["65 miles/hr"]Interpreter["Quantity"]["1000 Canadian dollars"]Interpret quantities in natural language:
Interpreter["Quantity"]["a half year"]Interpreter["Quantity"]["one grand"]Restrict and convert to a unit:
Interpreter[Restricted["Quantity", "Euro"]]["$1000"]Interpreter[Restricted["Quantity", "Kilometer", {1, 100}]]["20 miles"]Restrict to a given physical quantity:
Interpreter[Restricted["Quantity", QuantityVariable["Time"]]][{"20 km", "1.5 hr"}]Interpreter[QuantityVariable["Age"]]["10 years"]Accept unitless inputs in the presence of an appropriate restriction:
Interpreter[Restricted[QuantityVariable["Money"]]]["100"]Interpreter[Restricted["Quantity", "Hours"]]["five"]Interpreter[Restricted["Quantity", Automatic, Automatic, 3]]["1.2345 m"]See Also
Quantity QuantityVariable QuantityVariablePhysicalQuantity QuantityVariableCanonicalUnit Interpreter SemanticImport Restricted Failure UnitConvert
Interpreter Types: StructuredQuantity ComputedQuantity PhysicalQuantity Age Percent PercentFraction HeuristicPercent CurrencyAmount CurrencyName Number ComputedAge ComputedPercent ComputedPercentFraction ComputedHeuristicPercent ComputedCurrencyAmount SemanticNumber ComputedNumber
Text Contents: Quantity
Related Guides
History
Introduced in 2014 (10.0)