Last active
April 17, 2021 04:38
-
-
Save eanmos/039d46e4b53c8e3af9aca31a1aab9fc1 to your computer and use it in GitHub Desktop.
Prolog Homework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
?- dynamic point/2. | |
?- dynamic male/1. | |
?- dynamic female/1. | |
shouldSave(point). | |
shouldSave(male). | |
shouldSave(female). | |
shouldSave(son). | |
shouldSave(addPath). | |
shouldSave(shouldSave). | |
point(a, [b, c]). | |
point(b, [c, d]). | |
point(d, [e]). | |
addPath(From, To) :- | |
point(From, DestList), | |
member(To, DestList). | |
addPath(From, To) :- | |
point(From, DestList), | |
\+ member(To, DestList), | |
append(DestList, [To], NewDestList), | |
retract(point(From, DestList)), | |
assert(point(From, NewDestList)). | |
son(charles, mary). | |
daughter(mary, olivia). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell('save.pl'), forall(shouldSave(X), listing(X)), told. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- dynamic point/2. | |
point(a, [b, c]). | |
point(b, [c, d]). | |
point(d, [e]). | |
:- dynamic male/1. | |
male(max). | |
male(john). | |
:- dynamic female/1. | |
female(mary). | |
female(alex). | |
son(charles, mary). | |
addPath(From, To) :- | |
point(From, DestList), | |
member(To, DestList). | |
addPath(From, To) :- | |
point(From, DestList), | |
\+ member(To, DestList), | |
append(DestList, [To], NewDestList), | |
retract(point(From, DestList)), | |
assert(point(From, NewDestList)). | |
shouldSave(point). | |
shouldSave(male). | |
shouldSave(female). | |
shouldSave(son). | |
shouldSave(addPath). | |
shouldSave(shouldSave). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment