Hi Wolf, not sure what you are testing. Note that the timing depends on how you test it.
The any(x -> x < 3, numbers) might look slow if you use @time, but that's because the anonymous function keeps getting recompiled for every call. Maybe that's what you mean?
You can easily bypass this by placing it inside another function. Also you can use BenchmarkTools.@btime instead to ignore the compilation time.
julia> numbers = [1, 2, 3, 4, 5];
julia> @time any(x -> x < 3, numbers)
0.006801 seconds (2.74 k allocations: 183.680 KiB, 99.01% compilation time)
true
julia> @time any(numbers .< 3)
0.000012 seconds (3 allocations: 128 bytes)
true
julia> any_less(numbers, value) = any(x -> x < value, numbers)
any_less (generic function with 1 method)
julia> @time any_less(numbers, 3)
0.009657 seconds (6.90 k allocations: 456.047 KiB, 99.76% compilation time)
true
julia> @time any_less(numbers, 3)
0.000005 seconds
true
But perhaps you are talking about something else?
Wolf Nederpel
Regarding the first example it's interesting to note that while for small arrays and searching for a frequent occurence using x->xx<num seems directly related to the rarity of the searched for condition. Even for small arrays where the condition does not occur, this approah is significantly slower than the other approaches (and the vectorized approach is fastest).