#1. Dot-comparison operators work like this:
julia> [1,2,3].<[4,5,6]
3-element BitArray:
true
true
true
#2. Simple comparison operators work like this:
julia> [1,2,3]<[4,5,6]
true
which is a shorthand for this:
E.g.
(h.!=0) & (k.>=0) & (l.>=0) & (A.>=0.05*<max(A))
I appreciate that universal equality is high on the priority list,
and - as you earlier said - design decisions are always compromises.
Just for the record.
Fortran and Matlab comparison operators both default to elementwise:
Fortran:
print *, [1,2,3]==[1,2,3]
T T T
Matlab:
>> [1,2,3]==[1,2,3]
ans =
1 1 1
Array comparison is a separate construct. For Matlab:
isequal(a,b)
ans =
1
For Fortran one must use:
print *, all([1,2,3],[1,2,3])
T
Because it is compiled, I assume it does not have to calculate
all elements of the inner elementwise comparison either.
Julia's design decision is obviously different in this respect,
elementwise comparisons are inferior to whole arrray comparisons.
There are any() and all() to transform a vector of Booleansto Bool to be used in an if-statement.Also very readable.
I personally prefer the consistency of the (.) family operators, but you could always embrace the power of Julia and define it as you like. Just place the following in your $HOME/.juliarc.jl file:import Base.islessisless{T,N}(l::AbstractArray{T,N}, r::T) = l .< risless{T,N}(l::T, r::AbstractArray{T,N}) = l .< rIt seemed to work with some cursory testing (although there was a warning about having the isless(AbstractArray, AbstractArray) version defined first, even though this is in abstractarray.jl).
global < # prevent the default import of < from Base
<(x,y) = applicable(Base.(:.<), x, y) ? Base.(:.<)(x,y) : Base.(:<)(x,y)
You should never monkey patch functions in Base like that to behave differently for types that Base knows about.