🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.prolog
Article #602

Re: Standard behavior?

#602
From: Craig D. Singer
Date: Mon, 12 May 1986 12:56
42 lines
1934 bytes
In article <7233@duke.UUCP> cds@duke.UUCP (Craig D. Singer) writes:
>In article <6500005@uicsl> gooley@uicsl.UUCP writes:
>>
>>Consider the following trivial predicate:
>>
>>a([]).
>>a(_).
>>
>>Given the query :-a([]). , C-Prolog finds one match and UNSW Prolog finds two.
>>Which is standard behavior?  How do other implementations behave?
>
>I do not have the authority to say which is "standard" behavior, if by that
>you mean which is found more commonly in implementations.  However, any book
>on "vanilla" Prolog will tell you that "_" matches to anything, including a
>null list, so I would indeed be annoyed by C-Prolog if it did not find two
>matches.  Anybody disagree?

Well, after I posted the above response I went ahead and checked out the
version of C-Prolog which comes with 4.2/4.3 BSD and it DOES find two
matches.  The way to note this is to expand the predicate as follows:

a([],2).
a(_,3).

Then ask the query a([],X).  The response will be:

X = 2

after which you can type a semicolon and hit return, which produces:

X = 3

yes

So C-Prolog (and, I would guess, any prolog) finds both matches.
-- 
 

Craig D. Singer, Dept. of Computer Science, Duke University
Durham, NC 27706-2591.  Phone (919) 684-5110  (ext.20)
CSNET: cds@duke        UUCP: ...!decvax!duke!cds
ARPA:  cds%duke@csnet-relay
Technical Details
Message-ID: <7234@duke.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!unc!mcnc!duke!cds
References: <6500005@uicsl> <7233@duke.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site duke.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!unc!mcnc!duke!cds
From: cds@duke.UUCP (Craig D. Singer)
Newsgroups: net.lang.prolog
Subject: Re: Standard behavior?
Message-ID: <7234@duke.UUCP>
Date: Mon, 12-May-86 08:56:24 EDT
Article-I.D.: duke.7234
Posted: Mon May 12 08:56:24 1986
Date-Received: Tue, 13-May-86 19:28:47 EDT
References: <6500005@uicsl> <7233@duke.UUCP>
Reply-To: cds@duke.UUCP (Craig D. Singer)
Organization: Duke University
Lines: 42