Prolog, find minimum in a list

前端 未结 13 1928
佛祖请我去吃肉
佛祖请我去吃肉 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 01:42

    % find minimum in a list

    min([Y],Y):-!.
    
    min([H|L],H):-min(L,Z),H==Z.
    

    % so whattaya think!

提交回复
热议问题