Created
June 7, 2016 21:04
-
-
Save hutchison/45aa6748e64fe9df0a6115999bd771b6 to your computer and use it in GitHub Desktop.
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
% vim:set noet sts=0 sw=8 ts=8 ft=prolog: | |
:- [hauptstadt]. | |
hilfe :- | |
write('Anfragen mit:'), nl, | |
tab(3), write('?- findeHauptstadt.'), nl, | |
write('Sichern der aktuellen Daten mit:'), nl, | |
tab(3), write('?- speichern.'), nl. | |
findeHauptstadt :- | |
write('Geben Sie das Land ein: '), | |
read(Land), | |
( | |
hauptstadt(Land, Hauptstadt) -> ( | |
write('Die Hauptstadt ist: '), | |
write(Hauptstadt) | |
); ( | |
write('Die Hauptstadt konnte nicht gefunden werden.'), nl, | |
write('Bitte geben Sie sie ein:'), nl, | |
read(Hauptstadt), | |
assertz(hauptstadt(Land, Hauptstadt)) | |
) | |
). | |
speichern :- | |
open('hauptstadt.pl', write, Stream), | |
write(Stream, ':- dynamic hauptstadt/2.\n\n'), | |
forall( | |
hauptstadt(Land, Hauptstadt), | |
format(Stream, "hauptstadt('~w', '~w').\n", [Land, Hauptstadt]) | |
), | |
close(Stream). |
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 hauptstadt/2. | |
hauptstadt('Deutschland', 'Berlin'). | |
hauptstadt('Frankreich', 'Paris'). | |
hauptstadt('Schweden', 'Stockholm'). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment