Compare commits
3 commits
28168cb0f1
...
a1187238c3
Author | SHA1 | Date | |
---|---|---|---|
a1187238c3 | |||
26c339b8f8 | |||
c6f829a60f |
4 changed files with 31 additions and 3 deletions
Binary file not shown.
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 23 KiB |
Binary file not shown.
|
@ -131,6 +131,8 @@
|
||||||
Het unificatie-algoritme is gebaseerd op Robinsons Unificatie-algoritme, zoals beschreven door~\cite{boizumault-1993}, met inspiratie van~\cite{russell2016}.
|
Het unificatie-algoritme is gebaseerd op Robinsons Unificatie-algoritme, zoals beschreven door~\cite{boizumault-1993}, met inspiratie van~\cite{russell2016}.
|
||||||
Merk op dat er gebruik gemaakt wordt van de \textit{occurs check}.
|
Merk op dat er gebruik gemaakt wordt van de \textit{occurs check}.
|
||||||
|
|
||||||
|
De broncode voor het algoritme kan teruggevonden worden in \texttt{prolog/logic/unification.kt}.
|
||||||
|
|
||||||
\subsection{Cut}\label{subsec:cut}
|
\subsection{Cut}\label{subsec:cut}
|
||||||
|
|
||||||
De cut operator geeft altijd een \mintinline{kotlin}{Result.failure(AppliedCut)} terug wanneer \mintinline{kotlin}{satisfy} wordt opgeroepen.
|
De cut operator geeft altijd een \mintinline{kotlin}{Result.failure(AppliedCut)} terug wanneer \mintinline{kotlin}{satisfy} wordt opgeroepen.
|
||||||
|
@ -150,6 +152,10 @@
|
||||||
In dit geval zal de \mintinline{kotlin}{AppliedShift} steeds doorgespeeld worden, totdat de \mintlinline{kotlin}{Reset} de uitzondering opvangt.
|
In dit geval zal de \mintinline{kotlin}{AppliedShift} steeds doorgespeeld worden, totdat de \mintlinline{kotlin}{Reset} de uitzondering opvangt.
|
||||||
Daarna gaat het programma verder met de nieuwe substituties en continuatie.
|
Daarna gaat het programma verder met de nieuwe substituties en continuatie.
|
||||||
|
|
||||||
|
De broncode voor de meta abstracties kan teruggevonden worden in
|
||||||
|
|
||||||
|
\texttt{prolog/builtins/delimitedContinuationsOperators.kt}.
|
||||||
|
|
||||||
|
|
||||||
\section{Resultaat}\label{sec:resultaat}
|
\section{Resultaat}\label{sec:resultaat}
|
||||||
|
|
||||||
|
@ -167,7 +173,7 @@
|
||||||
De code in~\ref{lst:nesting} komt bijvoorbeeld in de meeste termen voor, weliswaar in verschillende vorm.
|
De code in~\ref{lst:nesting} komt bijvoorbeeld in de meeste termen voor, weliswaar in verschillende vorm.
|
||||||
|
|
||||||
\begin{listing}[H]
|
\begin{listing}[H]
|
||||||
\begin{minted}{kotlin}
|
\begin{minted}{kotlin}
|
||||||
/* Function entry logic */
|
/* Function entry logic */
|
||||||
unifyLazy(a, b, subs).forEach { firstResult ->
|
unifyLazy(a, b, subs).forEach { firstResult ->
|
||||||
firstResult.map { firstSubs ->
|
firstResult.map { firstSubs ->
|
||||||
|
@ -183,8 +189,8 @@
|
||||||
is AppliedCut -> /* Cut logic */
|
is AppliedCut -> /* Cut logic */
|
||||||
is AppliedShift -> /* Shift logic */
|
is AppliedShift -> /* Shift logic */
|
||||||
} } ) } } }
|
} } ) } } }
|
||||||
\end{minted}
|
\end{minted}
|
||||||
\caption{Voorbeeld van geneste boilerplate code}\label{lst:nesting}
|
\caption{Voorbeeld van geneste boilerplate code}\label{lst:nesting}
|
||||||
\end{listing}
|
\end{listing}
|
||||||
|
|
||||||
% KERN: Overerving zorgt voor boilerplate
|
% KERN: Overerving zorgt voor boilerplate
|
||||||
|
|
22
examples/basics/summer.pl
Normal file
22
examples/basics/summer.pl
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
summer(Start, End, 0) :- Start == End.
|
||||||
|
summer(Start, End, Sum) :-
|
||||||
|
Start \== End,
|
||||||
|
Next is Start + 1,
|
||||||
|
summer(Next, End, Rest),
|
||||||
|
writeln(rest(Rest)),
|
||||||
|
Sum is Start + Rest,
|
||||||
|
writeln(sum(Sum)).
|
||||||
|
|
||||||
|
my_sum :-
|
||||||
|
write('Enter start: '),
|
||||||
|
read(Start),
|
||||||
|
write('Enter end: '),
|
||||||
|
read(End),
|
||||||
|
summer(Start, End, Sum),
|
||||||
|
write('The sum is: '),
|
||||||
|
write(Sum), nl.
|
||||||
|
|
||||||
|
main :-
|
||||||
|
summer(1, 5, Sum).
|
||||||
|
|
||||||
|
:- initialization(main).
|
Reference in a new issue