Using the loop macro you can find the maximum of some numerical function
f, applied
to each element of a list by
(loop for x in list maxmimize (funcall f x))
But I want to return the x such that (funcall f x) is maximum
and I would like to write something like this:
(loop for x in list argmaximize (funcall f x))
Is there some loop keyword that would do this?
If there isn't such a keyword what's the most succinct way to
do this with the loop macro?
There isn't a keyword for it.
(loop with max-val = (car list)
for x in (cdr list)
when (> (funcall f x) max-val)
do (setq max-val x))
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 343 |
Nodes: | 16 (3 / 13) |
Uptime: | 31:22:26 |
Calls: | 7,557 |
Calls today: | 1 |
Files: | 12,733 |
Messages: | 5,655,714 |