Questions tagged [iso-prolog]

ISO/IEC has standardized Prolog. The standard is maintained by ISO/IEC JTC1/SC22/WG17.

ISO/IEC has standardized Prolog. The standard is maintained by ISO/IEC JTC1/SC22/WG17.

The currently valid Prolog standard documents can be obtained from national member bodies like ANSI or directly from ISO. Overview of defined features.

Stack Overflow contributions about the standard documents:

143 questions
2
votes
2 answers

Define an operator in prolog

I need to define a new operator that associates in the following way (1 newop 2) / (2 newop) / a The parenthesis were just used to give an understanding of the associativity of the new op So. :- op(A, B, newop). Which would be the values for A…
Alessandroempire
  • 1,640
  • 4
  • 31
  • 54
2
votes
1 answer

Prolog infix operators of same precedence one xfy and the other yfx with two sequential operators

In trying to understand just infix operators of the type xfy and yfx with the same precedence and in sequence I see that there are just four combinations. using a = xfy right-associative b = yfx left-associative There is aa e.g. 1 xfy 2 xfy 3 …
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
2
votes
2 answers

why is this still raising an exception despite using catch in prolog?

when using this code this exception was raised and didn't return failure: in Sicstus Polog: Syntax error in number_codes/2 ! number syntax ! in line 0 in SWI-Prolog: ERROR: number_chars/2: Syntax error: Illegal…
2
votes
3 answers

What is the modern popular standard Prolog that hobby Prolog interpreters should aim for?

I'm writing a Prolog interpreter as an exercise and wondering what I should be aiming for. Unfortunately there are many versions of Prolog to choose from and they are documented to various degrees. I quickly found this question from someone who was…
Geo
  • 750
  • 7
  • 17
2
votes
1 answer

Is it always necessary to use '.\n' when reading streams in Prolog?

I'm using pipes to communicate two Prolog processes and every time I reached a read/2 predicate to read a message from my pipe, the program blocked and remained like that. I couldn't understand why that happened (I tried with extremely simple…
Carles Araguz
  • 1,157
  • 1
  • 17
  • 37
2
votes
2 answers

Prolog reassigning operators

I'm new to prolog and I'm trying to reassign operators in prolog by changing their precedence. I'm running into 4 errors for the following: :-op(1000,yf,+). %unary plus% :-op(1000,yf,-). %unary minus% :-op(750,yfx,"%"). %modulo% The first…
pauliwago
  • 6,373
  • 11
  • 42
  • 52
2
votes
1 answer

Finding all predicates with the same arity

Is it possible to pose a query such as ?- X(C). that can return all the predicates that have arity 1? In general, is it possible to refer to a predicate name by using a variable?
Roberta G
  • 23
  • 2
2
votes
3 answers

Equivalent of Python pickling in SWI Prolog?

I've got a Prolog program where I'm doing some brute force search on all strings up to a certain length. I'm checking which strings match a certain pattern, keeping adding patterns until hopefully I find a set of patterns that covers all strings. I…
jmite
  • 8,171
  • 6
  • 40
  • 81
1
vote
1 answer

appendAll - Append a list to all lists within a list

I'm trying to find a way to append a list to all lists within a list. Something like: appendAll([a,b],[[q,w],[z,x]],X). X = [[a,b,q,w],[a,b,z,x]]. I'm still new to prolog and nested lists are throwing me off quite a bit. I've been staring at this…
ftsk33
  • 145
  • 1
  • 2
  • 4
1
vote
4 answers

Getting the minimum value of a list

I am trying to find the minimum value of a list (as a learning experience, so without min). My approach is the following: minimo([X], X). minimo([X,Y|Tail], N):- (X > Y, minimo([Y,Tail], Y)); (X <= Y, minimo([X,Tail], X)). This gives me the…
Trufa
  • 39,971
  • 43
  • 126
  • 190
1
vote
0 answers

Exception for "effect of operation is undefined"

SICStus Prolog offers an abstract datatype ("mutable term") for efficient backtrackable destructive assignment. The user's manual subsection on mutable terms states: Please note: the effect of unifying two mutables is undefined. Let's say another…
repeat
  • 18,496
  • 4
  • 54
  • 166
1
vote
1 answer

Peeking past end-of-file with SICStus Prolog

Suppose I have an empty file (imaginatively called empty) in the current directory and run the following query. Using SICStus Prolog 4.7.1 (Intel x86-64): | ?- open(empty,read,S,[eof_action(eof_code)]), …
repeat
  • 18,496
  • 4
  • 54
  • 166
1
vote
1 answer

What are legitimate / proper System Errors in ISO-Prolog?

TL;DR: This question is about Prolog implementation details. Proceed at your own risk. You've been warned:) According to ISO/IEC 13211-1995 "7.12 Errors": 7.12.2 Error classification [...] j) There may be a System Error at any stage of …
repeat
  • 18,496
  • 4
  • 54
  • 166
1
vote
0 answers

Unclear phrase in the definition of retract/1

There is something about retract/1 that doesn't make sense to me. According to ISO/IEC 13211-1:1995: 8.9.3 retract/1 8.9.3.1 Description retract(Clause) is true iff the database contains at least one dynamic procedure with a clause Clause …
repeat
  • 18,496
  • 4
  • 54
  • 166
1
vote
1 answer

SWI Prolog description of call/1: "clauses may have variables as subclauses"?

The description of call/1 says: call(:Goal) Invoke Goal as a goal. Note that clauses may have variables as subclauses, which is identical to call/1. I don't understand "clauses may have variables as subclauses". Can anyone give an example?
David Tonhofer
  • 14,559
  • 5
  • 55
  • 51