Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ex 4.2 #7 is probably correct definition #45

Open
BrazilForever11 opened this issue Oct 29, 2018 · 2 comments
Open

Ex 4.2 #7 is probably correct definition #45

BrazilForever11 opened this issue Oct 29, 2018 · 2 comments

Comments

@BrazilForever11
Copy link

I tried the following assert([[1,2]|4]). and it returned true. Why is it labelled as syntactically incorrect?

@dragonwasrobot
Copy link
Owner

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 :)

@hailangvn
Copy link

hailangvn commented Nov 11, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants