kernelthread.com

BlooP

The Towers of Hanoi as a BlooP program.

The BlooP and FlooP languages are from Chapter XIII of Göedel, Escher, Bach: An Eternal Golden Braid by Douglas R. Hofstadter. BlooP mechanizes primitive-recursive functions, while FlooP mechanizes general-recursive ones.

# # The Towers Of Hanoi # BlooP # Copyright (C) 2002 Amit Singh. All Rights Reserved. # http://hanoi.kernelthread.com # define procedure ''minus'' [m,n]: block 0: begin if m < n, then: quit block 0; loop at most m + 1 times: block 1: begin if output + n = m, then: abort loop 1; output <= output + 1; block 1: end; block 0: end. define procedure ''hanoi'' [N,F,U,T]: block 0: begin if N < 1, then: quit block 0; block 1: begin cell(0) <= hanoi[minus[N, 1], F, T, U]; print[F,' --> ',T]; cell(0) <= hanoi[minus[N, 1], U, F, T]; block 1: end; block 0: end.

Download

hanoi.bloop