This question already has an answer here:
- No permission to modify static procedure 1 answer
During some playing around with different list predicates in SWI-Prolog (SWISH), I was trying to check if an atom a
was part of the list List1
which I defined in the program as List1 = [a,b,c,d]
.
I formulated my query as member(a, List1).
, expecting something along the lines of a simple 'yes' (just as it shows in this youtube video at 59:25), but instead I got a warning
Singleton variables: [List1]
and an error
No permission to modify static procedure `(=)/2'
From what I understand from looking this up online, the warning is not that important here. I do not understand, however, why I get an error message while a
is clearly a member of List1
.
I tried this in two different ways:
1) By adding List1 = [a,b,c,d].
to the program and querying with member(a,List1).
(which resulted in the error above);
2) By passing List1 = [a,b,c,d]
directly to the interpreter and then using the same query ( member(a,List1).
), which resulted in an endless amount of results where a
shifted positions in the Head of the list, like so:
List1 = [a|_1186]
List1 = [_1062, a|_1070]
List1 = [_1062, _1068, a|_1076]
List1 = [_1062, _1068, _1074, a|_1082]
List1 = [_1062, _1068, _1074, _1080, a|_1088]
Is this something about the specific Prolog version I am using, or am I missing something very simple?
EDIT
I was aware that a similar question was posed here , but I did not manage to fully understand the answer (nor the question) as it was immediately going about things as dynamic
which I have not yet encountered in Prolog. I was looking for a more general, more 'high-level' answer which I have found by posing this question.