Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

21 May, 2024: Computers section is temporarily disabled for maintenance. It will take several days before it's back.


devel / comp.lang.prolog / Syntax errors

SubjectAuthor
* Syntax errorssolitary....@gmail.com
`- Re: Syntax errorsJulio Di Egidio

1
Syntax errors

<ad64ab38-58f0-4918-803d-567a224d132fn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1160&group=comp.lang.prolog#1160

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:adf:fe06:0:b0:1e5:95ad:b6bc with SMTP id n6-20020adffe06000000b001e595adb6bcmr1237100wrr.191.1645656639479;
Wed, 23 Feb 2022 14:50:39 -0800 (PST)
X-Received: by 2002:a25:287:0:b0:61d:8134:966 with SMTP id 129-20020a250287000000b0061d81340966mr1656869ybc.217.1645656638692;
Wed, 23 Feb 2022 14:50:38 -0800 (PST)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!pasdenom.info!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.128.87.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Wed, 23 Feb 2022 14:50:38 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=162.255.44.69; posting-account=lMndggoAAACR6bdLBlBjeKrA4qihooHu
NNTP-Posting-Host: 162.255.44.69
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ad64ab38-58f0-4918-803d-567a224d132fn@googlegroups.com>
Subject: Syntax errors
From: solitary.wanderer52@gmail.com (solitary....@gmail.com)
Injection-Date: Wed, 23 Feb 2022 22:50:39 +0000
Content-Type: text/plain; charset="UTF-8"
 by: solitary....@gmail.c - Wed, 23 Feb 2022 22:50 UTC

I am a newbie in Prolog and I've been reading the Prolog section in "Seven Languages in Seven Weeks".

He introduces some basic elements of the language with this file:
friends.pl
---------------
likes(wallace, cheese).
likes(grommit, cheese).
likes(wendolene, sheep).

friend(X, Y) :- \+(X = Y), likes(X, Z), likes(Y, Z).

When I consult that with Gnu Prolog (which variant the author also uses), I get 2 compile errors:

| ?- consult('D:/Steve - D/Documents - D/GNU-Prolog/friends.pl').
compiling D:/Steve - D/Documents - D/GNU-Prolog/friends.pl for byte code...
D:/Steve - D/Documents - D/GNU-Prolog/friends.pl:1:6: syntax error: . or operator expected after expression
D:/Steve - D/Documents - D/GNU-Prolog/friends.pl:5:14: syntax error: . or operator expected after expression
2 error(s)
compilation failed

(15 ms) no

For the life of me it looks like I typed in the same example as in the book and that there should be no errors.

Any help would be appreciated.

Steve

Re: Syntax errors

<5d5bc312-e20b-4015-bf51-35d6801653bdn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=1161&group=comp.lang.prolog#1161

  copy link   Newsgroups: comp.lang.prolog
X-Received: by 2002:a1c:a704:0:b0:37f:abe2:d96b with SMTP id q4-20020a1ca704000000b0037fabe2d96bmr10155039wme.28.1645688881987;
Wed, 23 Feb 2022 23:48:01 -0800 (PST)
X-Received: by 2002:a81:9895:0:b0:2d7:7e75:9ba8 with SMTP id
p143-20020a819895000000b002d77e759ba8mr1258322ywg.130.1645688881318; Wed, 23
Feb 2022 23:48:01 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.128.87.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.prolog
Date: Wed, 23 Feb 2022 23:48:01 -0800 (PST)
In-Reply-To: <ad64ab38-58f0-4918-803d-567a224d132fn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=93.41.100.106; posting-account=F3H0JAgAAADcYVukktnHx7hFG5stjWse
NNTP-Posting-Host: 93.41.100.106
References: <ad64ab38-58f0-4918-803d-567a224d132fn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5d5bc312-e20b-4015-bf51-35d6801653bdn@googlegroups.com>
Subject: Re: Syntax errors
From: julio@diegidio.name (Julio Di Egidio)
Injection-Date: Thu, 24 Feb 2022 07:48:01 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Julio Di Egidio - Thu, 24 Feb 2022 07:48 UTC

On Wednesday, 23 February 2022 at 23:50:41 UTC+1, solitary....@gmail.com wrote:

> I am a newbie in Prolog and I've been reading the Prolog section in "Seven Languages in Seven Weeks".

A pretty absurd proposition if you ask me. :) All the more so for Prolog in
particular, which is utterly "exotic", indeed neither imperative nor functional.

> He introduces some basic elements of the language with this file:
> friends.pl
> ---------------
> likes(wallace, cheese).
> likes(grommit, cheese).
> likes(wendolene, sheep).
>
> friend(X, Y) :- \+(X = Y), likes(X, Z), likes(Y, Z).
>
> When I consult that with Gnu Prolog (which variant the author also uses), I get 2 compile errors:
>
> | ?- consult('D:/Steve - D/Documents - D/GNU-Prolog/friends.pl').
> compiling D:/Steve - D/Documents - D/GNU-Prolog/friends.pl for byte code...
> D:/Steve - D/Documents - D/GNU-Prolog/friends.pl:1:6: syntax error: . or operator expected after expression
> D:/Steve - D/Documents - D/GNU-Prolog/friends.pl:5:14: syntax error: . or operator expected after expression
> 2 error(s)
> compilation failed
>
> (15 ms) no
>
> For the life of me it looks like I typed in the same example as in the book and that there should be no errors.
>
> Any help would be appreciated.

Surely works for me:

---------------------------------------------------
GNU Prolog 1.5.0 (64 bits)
Compiled Jul 8 2021, 12:33:56 with cl
Copyright (C) 1999-2021 Daniel Diaz

| ?- [user].
compiling user for byte code...
likes(wallace, cheese).
likes(grommit, cheese).
likes(wendolene, sheep).

friend(X, Y) :- \+(X = Y), likes(X, Z), likes(Y, Z).

user compiled, 6 lines read - 881 bytes written, 8350 ms

(16 ms) yes
| ?-
---------------------------------------------------

(There is ctrl+D after the code to close the user stream.)

Consulting from a file would be equivalent, so maybe you have extra-characters
in the file you haven't noticed or some file encoding issues (i.e. it's not really a
plain text file): that Prolog code anyway is valid.

Rather, the code doesn't seem correct: that \+(X=Y) in that position just won't
cut it... but I do not have the book and I can't guess what's going wrong there,
unless you are simply miscopying.

Julio


devel / comp.lang.prolog / Syntax errors

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor