Description

Index

Warning

In the examples in the documentation below, the methods are not prefixed by the module name even if they are private.

julia> using CTBase
julia> x = 1
julia> private_fun(x) # throw an error

must be replaced by

julia> using CTBase
julia> x = 1
julia> CTBase.private_fun(x)

However, if the method is reexported by another package, then, there is no need of prefixing.

julia> module OptimalControl
           import CTBase: private_fun
           export private_fun
       end
julia> using OptimalControl
julia> x = 1
julia> private_fun(x)

Documentation

CTBase.DescVarArgConstant

DescVarArg is a Vararg of symbols. DescVarArg is a type alias for a Vararg of symbols.

julia> const DescVarArg = Vararg{Symbol}

See also: Description.

source
CTBase.DescriptionType

A description is a tuple of symbols. Description is a type alias for a tuple of symbols.

julia> const Description = Tuple{DescVarArg}

See also: DescVarArg.

Example

Base.show is overloaded for descriptions, that is tuple of descriptions are printed as follows:

julia> display( ( (:a, :b), (:b, :c) ) )
(:a, :b)
(:b, :c)
source
Base.showMethod
show(
    io::IO,
    _::MIME{Symbol("text/plain")},
    descriptions::Tuple{Vararg{Tuple{Vararg{Symbol}}}}
)

Print a tuple of descriptions.

Example

julia> display( ( (:a, :b), (:b, :c) ) )
(:a, :b)
(:b, :c)
source
CTBase.addMethod
add(
    x::Tuple{Vararg{Tuple{Vararg{Symbol}}}},
    y::Tuple{Vararg{Symbol}}
) -> Tuple{Tuple{Vararg{Symbol}}}

Add the description y to the tuple of descriptions x if x does not contain y and return the new tuple of descriptions.

Throw an exception (IncorrectArgument) if the description y is already contained in x.

Example

julia> descriptions = ()
julia> descriptions = add(descriptions, (:a,))
(:a,)
julia> descriptions = add(descriptions, (:b,))
(:a,)
(:b,)
julia> descriptions = add(descriptions, (:b,))
ERROR: IncorrectArgument: the description (:b,) is already in ((:a,), (:b,))
source
CTBase.addMethod
add(
    _::Tuple{},
    y::Tuple{Vararg{Symbol}}
) -> Tuple{Tuple{Vararg{Symbol}}}

Return a tuple containing only the description y.

Example

julia> descriptions = ()
julia> descriptions = add(descriptions, (:a,))
(:a,)
julia> print(descriptions)
((:a,),)
julia> descriptions[1]
(:a,)
source
CTBase.completeMethod
complete(list::Symbol...; descriptions)

Return one description from a list of Symbols list and a set of descriptions D. If multiple descriptions are possible, then the first one is selected.

If the list is not contained in any of the descriptions, then an exception is thrown.

Example

julia> D = ((:a, :b), (:a, :b, :c), (:b, :c), (:a, :c))
(:a, :b)
(:b, :c)
(:a, :c)
julia> complete(:a; descriptions=D)
(:a, :b)
julia> complete(:a, :c; descriptions=D)
(:a, :b, :c)
julia> complete((:a, :c); descriptions=D)
(:a, :b, :c)
julia> complete(:f; descriptions=D)
ERROR: AmbiguousDescription: the description (:f,) is ambiguous / incorrect
source
CTBase.removeMethod
remove(
    x::Tuple{Vararg{Symbol}},
    y::Tuple{Vararg{Symbol}}
) -> Tuple{Vararg{Symbol}}

Return the difference between the description x and the description y.

Example

julia> remove((:a, :b), (:a,))
(:b,)
source