You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, its been many years since I've actively written Prolog, so unfortunately can't answer any questions with much confidence, however if you believe that there is an error in my solution feel free to submit a PR that fixes it :)
Hi Brazil,
I learned to use [filename] to load knowledge file. After I tried assert([[1,2]|4]) statement, I could not load knowledge file any more by that way. I need to quit swipl to clear the effect. So that statement already did wrong thing. IMHO, to test list term, we need to use list predicates. Below is the result of using member/2. Note there is no space before period '.' at the first answer.
?- member(X,[[1,2]|4]).
X = [1, 2].
?- member(X,[[1,2]|[4]]).
X = [1, 2] ;
X = 4.
So the [[1,2]|4] is incorrect as it does not give desired result, which is concatenate two list. I just don't know if the term syntactically is applicable or not. :)
By the way, thanks dragonwasrobot for sharing the solutions.
I tried the following
assert([[1,2]|4]).
and it returned true. Why is it labelled as syntactically incorrect?The text was updated successfully, but these errors were encountered: