| Did you know ... | Search Documentation: |
| Function min/2 |
The predicates
min_list/2 and max_list/2
from library library(lists)
This should really be extended to take vectors:
Min is min(ListOfExpressions).
as in
Min is min([1,-1,X*44,Y-3]).
Sometimes one has a set of pairs Key-Value and one wants to find the pair with the extremal value (either max or min) and also know the corresponding key:
?- min_entry_of_dict(_{a:1,b:2,c:3,d:1,e:1,f:5},K,V).
K = a,
V = 1.
?- max_entry_of_dict(_{a:3,b:5,c:4},K,V).
K = b,
V = 5.
?- extremal_entry_of_dict(_{a:1,b:2,c:3,d:1,e:1,f:5},K,V,min,latest).
K = e,
V = 1.
And so, code: extremal.pl
This totally does not use function min/2 or function max/2 at all.
(Why isn't there a special notation to distinguish functions from predicates anyway? One could write `min/~2` for example.)