There is no such function. There really should be - in fact, the existing maximum(f, itr) is IMO bad API, since it just duplicates maximum(map(f, itr)).
That said, I suggest you decide in your own code on how to treat the empty collection. That is:
if isempty(xs)
# do something (maybe throw an ArgumentError)
else
y, i = findmax(f, xs)
# potentially, if this is what you want (but I am only guessing)
if y < init
# do something
end
end
argmax(f, domain)
Return a value x from domain for which f(x) is maximised. If there are multiple maximal values for
f(x) then the first one will be found.