]> gitweb.factorcode.org Git - factor.git/blob - extra/logic/examples/hanoi2/hanoi2.factor
Switch to https urls
[factor.git] / extra / logic / examples / hanoi2 / hanoi2.factor
1 ! Copyright (C) 2019-2020 KUSUMOTO Norio.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: logic lists sequences assocs formatting ;
4 IN: logic.examples.hanoi2
5
6 LOGIC-PREDS: hanoi write-move ;
7 LOGIC-VARS: A B C X Y Z ;
8
9 { write-move X } [ X of [ printf ] each t ] callback
10
11 { hanoi L{ } A B C } fact
12
13 { hanoi L{ X . Y } A B C } {
14     { hanoi Y A C B }
15     { write-move { "move " X " from " A " to " B "\n" } }
16     { hanoi Y C B A }
17 } rule