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