Prolog, find minimum in a list

前端 未结 13 1953
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-07 01:25

in short: How to find min value in a list? (thanks for the advise kaarel)

long story:

I have created a weighted graph in amzi prolog and given 2 nodes, I am

13条回答
  •  感动是毒
    2020-12-07 02:02

    Solution without "is".

    min([],X,X).
    min([H|T],M,X) :- H =< M, min(T,H,X).
    min([H|T],M,X) :- M < H, min(T,M,X).
    min([H|T],X) :- min(T,H,X).
    

提交回复
热议问题