Terry007
Programmer
- Jun 9, 2010
- 2
hello I have two easy examples, but I'm greenhorn in prolog.
nodouble (x, list1, list2) - predicate delete duplicate values in List 1 and save them to List2
max (list, x) - predicate find max value from List and save it to X.
I find max from list as:
maxList([]).
maxList([E],E).
maxList([E,E2|T],L) :- maxList([E2|T],L1), max(L1,E,L).
but how to save it to x?
and for nodouble:
Dupli([],[]).
Dupli([X|Xs],[X,X|Ys]) :- dupli(Xs,Ys).
but it is not what I need..
nodouble (x, list1, list2) - predicate delete duplicate values in List 1 and save them to List2
max (list, x) - predicate find max value from List and save it to X.
I find max from list as:
maxList([]).
maxList([E],E).
maxList([E,E2|T],L) :- maxList([E2|T],L1), max(L1,E,L).
but how to save it to x?
and for nodouble:
Dupli([],[]).
Dupli([X|Xs],[X,X|Ys]) :- dupli(Xs,Ys).
but it is not what I need..