The below looks structurally the same as my last example (class A3). Is 
there a crucial difference that I am missing?

Thanks,
Jan

On Wednesday, 30 July 2014 23:20:36 UTC+2, ggggg wrote:
>
> If the number is available when the type is constructed, you can use it to 
> construct a different type based upon it's value. Does this do what you 
> want?
>
> abstract BaseA
> immutable AP <: BaseA
>    a
> end
> immutable AN <: BaseA
>    a
> end
> A(x,y) = y>0 ? AP(x) : AN(x)
> f(a::AP, x::Number) = x+a.a
> f(a::AN, x::Number) = x-a.a
> f(A(4,2323.2), 4)
> f(A(4,-2), 4)
>
> f(a::BaseA, x::Vector) = [f(a, xi) for xi in x]
> f(A(4,-2), [1:10])
> f(A(4,2), [1:10])
>
>
>

Reply via email to