🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #4110

Re: A Challenge

#4110
From: Denys Duchier
Date: Fri, 15 Dec 1989 16:47
20 lines
1280 bytes
[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
Technical Details
Message-ID: <8659@cs.yale.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!yale!cs.yale.edu
References: <11500022@hpldoda.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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)