2
0
Fork 0
mirror of https://github.com/MartinThoma/LaTeX-examples.git synced 2025-04-26 06:48:04 +02:00

Prolog-Beispiel

This commit is contained in:
Martin Thoma 2014-02-01 20:14:08 +01:00
parent 45b2c7a71c
commit 7d278dd745
5 changed files with 31 additions and 0 deletions

View file

@ -9,6 +9,17 @@ Eine interaktive Prolog-Sitzung startet man mit \texttt{swipl}.
In Prolog definiert man Terme.
\section{Syntax}
\section{Beispiele}
\subsection{Humans}
Erstelle folgende Datei:
\inputminted[linenos, numbersep=5pt, tabsize=4, frame=lines, label=human.pro]{prolog}{scripts/prolog/human.pro}
Kompiliere diese mit
\inputminted[numbersep=5pt, tabsize=4]{bash}{scripts/prolog/human.sh}
Dabei wird eine \texttt{a.out} Datei erzeugt, die man wie folgt
nutzen kann:
\inputminted[numbersep=5pt, tabsize=4]{bash}{scripts/prolog/human-2.sh}
\subsection{Zebrarätsel}
Folgendes Rätsel wurde von \url{https://de.wikipedia.org/w/index.php?title=Zebrar%C3%A4tsel&oldid=126585006}
entnommen:

View file

@ -0,0 +1,11 @@
$ ./a.out
Welcome to SWI-Prolog (Multi-threaded, 32 bits, Version 5.10.4)
Copyright (c) 1990-2011 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free
software, and you are welcome to redistribute it under certain
conditions. Please visit http://www.swi-prolog.org for details.
For help, use ?- help(Topic). or ?- apropos(Word).
?- human(socrates).
true.

View file

@ -0,0 +1,3 @@
human(bob).
human(socrates).
human(antonio).

View file

@ -0,0 +1,6 @@
$ swipl -c human.pro
% library(swi_hooks) compiled into pce_swi_hooks
% 0.00 sec, 2,224 bytes
% human.pro compiled 0.00 sec, 644 bytes
% /usr/lib/swi-prolog/library/listing compiled into
% prolog_listing 0.00 sec, 21,648 bytes