
February 26th, 2006, 11:03 AM
|
|
Registered User
|
|
Join Date: Apr 2005
Posts: 19
Time spent in forums: 9 h 53 m 53 sec
Reputation Power: 0
|
|
|
Prolog - Find missing elements of an ordered list
Hi,
I am trying to write a predicate that accepts a list of integers. It sorts this list and then determines if there are any gaps in the sequence:
? - game([2,6,7,5],X).
X = [3,4]
Here is what I have so far:
Code:
find_hole([],[]).
find_hole([H|T],End):-
Test is H +1,
find_hole(T,Final),
Test != Final,
Test::End.
game(List,Result) :- sort(List,Result), find_hole(Result,Done).
Any idea on what I am doing wrong?
Thanks for your help
|