-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from JuliaReach/schillic/basetype
Add Basetype module
- Loading branch information
Showing
4 changed files
with
82 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Basetype | ||
|
||
This section of the manual describes the `Basetype` module. | ||
|
||
```@contents | ||
Pages = ["Basetype.md"] | ||
Depth = 3 | ||
``` | ||
|
||
```@meta | ||
CurrentModule = ReachabilityBase.Basetype | ||
``` | ||
|
||
```@docs | ||
Basetype | ||
basetype | ||
``` |
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,62 @@ | ||
""" | ||
Basetype | ||
This module provides the functionality to obtain the base type of a type or object. | ||
""" | ||
module Basetype | ||
|
||
export basetype | ||
|
||
""" | ||
basetype(T::Type) | ||
Return the base type of the given type (i.e., without type parameters). | ||
### Input | ||
- `T` -- type | ||
### Output | ||
The base type of `T`. | ||
```jldoctest | ||
julia> using ReachabilityBase.Basetype | ||
julia> basetype(Float64) | ||
Float64 | ||
julia> basetype(Rational{Int}) | ||
Rational | ||
``` | ||
""" | ||
basetype(T::Type) = Base.typename(T).wrapper | ||
|
||
""" | ||
basetype(x) | ||
Return the base type of the given object (i.e., without type parameters). | ||
### Input | ||
- `x` -- object | ||
### Output | ||
The base type of `x`. | ||
### Examples | ||
```jldoctest | ||
julia> using ReachabilityBase.Basetype | ||
julia> basetype(1.0) | ||
Float64 | ||
julia> basetype(1//1) | ||
Rational | ||
``` | ||
""" | ||
basetype(x) = basetype(typeof(x)) | ||
|
||
end # module |
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