-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
collectionsData structures holding multiple items, e.g. setsData structures holding multiple items, e.g. setsdesignDesign of APIs or of the language itselfDesign of APIs or of the language itselfmathsMathematical functionsMathematical functions
Description
This surprised me:
julia> typeof(reduce(&, Int8(0), (Int8(4),)))
Int32It makes sense of + to widen the type to prevent overflow, but & cannot overflow. I tried to counteract the automatic widening by providing an explicit neutral element, but that didn't help.
I also notice that a + reduction widens Bool to Int64, while a & reduction does not widen it.
Should there be a widereduce in addition to reduce?
Should there be an optional argument T that lets people specify the return type?
AzamatB
Metadata
Metadata
Assignees
Labels
collectionsData structures holding multiple items, e.g. setsData structures holding multiple items, e.g. setsdesignDesign of APIs or of the language itselfDesign of APIs or of the language itselfmathsMathematical functionsMathematical functions