This repository has been archived on 2024-06-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coffee.pygments/tests/examplefiles/visualprolog/hanoi.pro
Thomas Linder Puls a54ad08770
Visual Prolog programming language (#2480)
Co-authored-by: Thomas Linder Puls <thomas.linder.puls@pdc.com>
Co-authored-by: Jean Abou-Samra <jean@abou-samra.fr>
2023-09-01 13:52:30 +02:00

25 lines
591 B
Prolog

class hanoi
predicates
hanoi : (unsigned N).
end class hanoi
implement hanoi
domains
pole = left; center; right.
clauses
hanoi(N) :- move(N, left, center, right).
class predicates
move : (unsigned N, pole A, pole B, pole C).
clauses
move(0, _, _, _) :- !.
move(N, A, B, C) :-
move(N-1, A, C, B),
stdio::writef("move a disc from % pole to the % pole\n", A, C),
move(N-1, B, A, C).
end implement hanoi
goal
console::init(),
hanoi::hanoi(4).