Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented dimenionOf methods for AbstractUnit and AbstractQuantity
- Loading branch information
Daniel Hümmer
committed
Mar 3, 2021
1 parent
8b892ca
commit feecb0c
Showing
11 changed files
with
343 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
function Base.show(io::IO, dimension::Dimension) | ||
output = _generateLongPrettyPrintingOutput(dimension) | ||
print(io, output) | ||
end | ||
|
||
function _generateLongPrettyPrintingOutput(dimension::Dimension) | ||
prettyString = _generateLongStringRepresentation(dimension) | ||
return "Dimension " * prettyString | ||
end | ||
|
||
function _generateLongStringRepresentation(dimension::Dimension) | ||
exponents = _getExponentsAsArray(dimension) | ||
prettyString = "" | ||
for exp in exponents | ||
prettyString = _addLongPrettyFactor_Dimension(prettyString, exp) | ||
end | ||
return prettyString | ||
end | ||
|
||
function _getExponentsAsArray(dimension::Dimension) | ||
exponents = [ | ||
("M", dimension.massExponent), | ||
("L", dimension.lengthExponent), | ||
("T", dimension.timeExponent), | ||
("I", dimension.currentExponent), | ||
("θ", dimension.temperatureExponent), | ||
("N", dimension.amountExponent), | ||
("J", dimension.luminousIntensityExponent) | ||
] | ||
return exponents | ||
end | ||
|
||
function _addLongPrettyFactor_Dimension(prettyString::String, exp::Tuple) | ||
(symbol, exponent) = exp | ||
|
||
expString = prettyPrintScientificNumber(exponent, sigdigits=2) | ||
addString = "$symbol^$expString" | ||
|
||
return _addStringWithWhitespace( prettyString, addString ) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.