It's actually pretty weird. It will take the shortcut if you pass it an
AbstractArray{Bool}, but only if it has 16 or more elements. For other
array types, it still never takes it.
On Thursday, June 18, 2015 at 12:07:48 PM UTC-4, Seth wrote:
>
> Thanks, Josh. I opened #11750
> <https://github.com/JuliaLang/julia/issues/11750>.
>
> On Thursday, June 18, 2015 at 11:04:29 AM UTC-5, Josh Langsfeld wrote:
>>
>> It seems 'any' calls 'mapreduce' which calls 'mapfoldl' which has a
>> specialization that will stop computing in the case of searching for a
>> single true or false value. However, it seems the call to mapreduce instead
>> goes to a more specific method that doesn't implement this shortcut. If
>> 'any' were to call mapfoldl directly, it would do the lazy computing.
>>
>> On Thursday, June 18, 2015 at 11:18:12 AM UTC-4, Seth wrote:
>>>
>>>
>>>
>>> julia> function bar(x)
>>> info("bar $x")
>>> x
>>> end
>>> bar (generic function with 1 method)
>>>
>>> julia> any(v->bar(v), [false, false, true, false, false])
>>> INFO: bar false
>>> INFO: bar false
>>> INFO: bar true
>>> INFO: bar false
>>> INFO: bar false
>>> true
>>>
>>> Is there a reason the rest of the elements in the collection are
>>> evaluated after the first true is encountered?
>>>
>>