{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/11774","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/11774/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/11774/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/11774/events","html_url":"https://github.com/JuliaLang/julia/pull/11774","id":89698266,"number":11774,"title":"WIP: Make `any` and `all` short-circuiting","user":{"login":"fcard","id":12222927,"avatar_url":"https://avatars.githubusercontent.com/u/12222927?v=3","gravatar_id":"","url":"https://api.github.com/users/fcard","html_url":"https://github.com/fcard","followers_url":"https://api.github.com/users/fcard/followers","following_url":"https://api.github.com/users/fcard/following{/other_user}","gists_url":"https://api.github.com/users/fcard/gists{/gist_id}","starred_url":"https://api.github.com/users/fcard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fcard/subscriptions","organizations_url":"https://api.github.com/users/fcard/orgs","repos_url":"https://api.github.com/users/fcard/repos","events_url":"https://api.github.com/users/fcard/events{/privacy}","received_events_url":"https://api.github.com/users/fcard/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":22,"created_at":"2015-06-20T01:28:10Z","updated_at":"2015-06-23T22:17:34Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/11774","html_url":"https://github.com/JuliaLang/julia/pull/11774","diff_url":"https://github.com/JuliaLang/julia/pull/11774.diff","patch_url":"https://github.com/JuliaLang/julia/pull/11774.patch"},"body":"Doesn't apply for `n < 16`, but that shouldn't be a big problem, right? There is apparently optimizations for small `n`, so I decided not to mess with that."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/114657877","html_url":"https://github.com/JuliaLang/julia/pull/11774#issuecomment-114657877","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/11774","id":114657877,"user":{"login":"fcard","id":12222927,"avatar_url":"https://avatars.githubusercontent.com/u/12222927?v=3","gravatar_id":"","url":"https://api.github.com/users/fcard","html_url":"https://github.com/fcard","followers_url":"https://api.github.com/users/fcard/followers","following_url":"https://api.github.com/users/fcard/following{/other_user}","gists_url":"https://api.github.com/users/fcard/gists{/gist_id}","starred_url":"https://api.github.com/users/fcard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fcard/subscriptions","organizations_url":"https://api.github.com/users/fcard/orgs","repos_url":"https://api.github.com/users/fcard/repos","events_url":"https://api.github.com/users/fcard/events{/privacy}","received_events_url":"https://api.github.com/users/fcard/received_events","type":"User","site_admin":false},"created_at":"2015-06-23T22:17:34Z","updated_at":"2015-06-23T22:17:34Z","body":"Hello, I am mostly done implementing this, but I reached a stumbling block.\r\nIs this a valid usage of `mapreduce`? \r\n\r\n```julia\r\njulia> mapreduce(x->(x == 1? true : x), |, 1:10)\r\n15\r\n```\r\n\r\nOr using `f::T -> Union{Bool, SomethingElse}` in general. If we reach an `true`, how do we know if there are any nonboolean results later that might modify the final result? In the case of `any` or `all`, it's a safe assumption to make that the predicate should return a `Bool`, but with `mapreduce`, I'd expect the transformer function to be allowed to return any value that can be used with the operator, and `|`/`&` can use booleans, integers and arrays, all in the same operation.\r\n\r\n(The current implementation actually assumes that predicates return booleans so this happens:\r\n```julia\r\njulia> mapreduce(Int, |, trues(15))\r\n1\r\n\r\njulia> mapreduce(Int, |, trues(16))\r\nERROR: TypeError: non-boolean (Int64) used in boolean context\r\n in mapreduce_impl at reduce.jl:327\r\n in _mapreduce at reduce.jl:151\r\n in mapreduce at reduce.jl:158\r\n```\r\n)"}}