On Thursday, May 7, 2015 at 11:55:59 AM UTC-5, Kristoffer Carlsson wrote:
>
> Boring but non allocating like list comprehension and anonymous function:
>
> m = typemin(Int16)
> for TUnit in TUnitS
>    m = max(m,TUnit.tau_max)
> end
>
>
Even more compact is to use a function as the first argument to maximum

julia> immutable foo
          bar::Int16
          baz::Float32
       end

julia> [foo(i,0.) for i in 1:10]
10-element Array{foo,1}:
 foo(1,0.0f0) 
 foo(2,0.0f0) 
 foo(3,0.0f0) 
 foo(4,0.0f0) 
 foo(5,0.0f0) 
 foo(6,0.0f0) 
 foo(7,0.0f0) 
 foo(8,0.0f0) 
 foo(9,0.0f0) 
 foo(10,0.0f0)

julia> maximum(x->x.bar,ans)
10



Reply via email to