m4 Macro
The Towers of Hanoi implemented using the m4 macro processing language.
dnl
dnl # The Towers Of Hanoi
dnl # m4
dnl # Copyright (C) 1998 Amit Singh. All Rights Reserved.
dnl # http://hanoi.kernelthread.com
dnl #
dnl # Tested under GNU m4 1.4
dnl # Use `m4 -DN=n <thisfile>' to run hanoi with n disks
dnl
define(`M', `move $1 --> $2') dnl
define(`T', `ifelse(eval($1 > 0), 1, `T(eval($1 - 1), $2, $4, $3)'
`M($2, $3)' `T(eval($1 - 1), $4, $3, $2)', )') dnl
ifdef(`N', `ifelse(eval(N > 0), 1, `T(N, 1, 3, 2)', `')')
dnl