Skip to content

Commit 8846297

Browse files
committed
Fix accidentally removed single argument argmin
1 parent 229d14d commit 8846297

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

base/reduce.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,32 @@ julia> argmin(acos, 0:0.1:1)
964964
"""
965965
argmin(f, domain) = mapfoldl(x -> (f(x), x), _rf_findmin, domain)[2]
966966

967+
"""
968+
argmin(itr)
969+
970+
Return the index or key of the minimal element in a collection.
971+
If there are multiple minimal elements, then the first one will be returned.
972+
973+
The collection must not be empty.
974+
975+
`NaN` is treated as less than all other values except `missing`.
976+
977+
See also: [`argmax`](@ref), [`findmin`](@ref).
978+
979+
# Examples
980+
```jldoctest
981+
julia> argmin([8, 0.1, -9, pi])
982+
3
983+
984+
julia> argmin([7, 1, 1, 6])
985+
2
986+
987+
julia> argmin([7, 1, 1, NaN])
988+
4
989+
```
990+
"""
991+
argmin(itr) = findmin(itr)[2]
992+
967993
"""
968994
indmin(itr) -> idx
969995

0 commit comments

Comments
 (0)