Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!yale!cs.yale.edu From: Duchier-Denys@cs.yale.edu (Denys Duchier) Newsgroups: comp.lang.prolog Subject: Re: A Challenge Message-ID: <8659@cs.yale.edu> Date: 15 Dec 89 16:47:39 GMT References: <11500022@hpldoda.UUCP> Sender: news@cs.yale.edu Reply-To: Duchier-Denys@cs.yale.edu (Denys Duchier) Organization: Computer Science, Yale University, New Haven, CT 06520-2158 Lines: 20 In-reply-to: patch@hpldoda.UUCP (Pat Chkoreff) [I tried to mail you, but somehow my mailer choked on your address] Your problem was somewhat underspecified. I assumed that you did not want any variables to become instantiated as a result of a call to good/1. The trick I use is List \= a which means that List must not be unifiable with atom a (in particular, it can't be a variable). I tested the following with sbprolog: good(Lists) :- are_lists(Lists,Length). is_list(List,Length) :- List \= a, List = [], Length = 0. is_list(List,Length) :- List \= a, List = [Head|Tail], is_list(Tail,TailLength), Length is 1 + TailLength. are_lists(Lists,Length) :- Lists \= a, Lists = []. are_lists(Lists,Length) :- Lists \= a, Lists = [Head|Tail], is_list(Head,Length), are_lists(Tail,Length). --Denys