Can someone explain how should the predefine predicate forall
to find the minimum values within a list?
For a list L
, you can use:
member(Min,L), forall(member(N,L), N>=Min).
However, while this is a nice demonstration of forall
, it is not efficient (square complexity instead of linear).
or you can use the predicate findall/3
findall(Value, minimumValues(Value), minimumValuesList)
it returns a list (minimumValuesList) with elements (all the minimum values, right).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With