-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
foldsum, maximum, reduce, foldl, etc.sum, maximum, reduce, foldl, etc.
Description
The documentation for mapreduce says that it is unspecified if the init key argument is used for non-empty collections. Since there is a single julia implementation leaving the behavior unspecified is bad. In general the init argument is a starting point that you want to combine with the rest. For example
sol = nlsolve(f!, initial_x)
# mapreduce doesn't specify if `init` is used. Need to use reduce(..., map(...))
if mapreduce(map(v -> v > 0, &, sol.zero, init=converged(sol))
return ...
else
...
endUsing the init argument to specify the result in case of an empty collection is a special case.
Metadata
Metadata
Assignees
Labels
foldsum, maximum, reduce, foldl, etc.sum, maximum, reduce, foldl, etc.