source:
trunk/essentials/sys-devel/m4/examples/hanoi.m4
Last change on this file was 3090, checked in by , 18 years ago | |
---|---|
File size: 374 bytes |
Line | |
---|---|
1 | divert(-1) |
2 | |
3 | # move(from, to) |
4 | define(`move', `Move one disk from `$1' to `$2'. |
5 | ') |
6 | |
7 | # _hanoi (cnt, from, to, aux) |
8 | define(`_hanoi', `ifelse(eval(`$1'<=1), 1, `move($2, $3)', |
9 | `_hanoi(decr($1), $2, $4, $3)move($2, $3)_hanoi(decr($1), $4, $3, $2)')') |
10 | |
11 | # hanoi (cnt) |
12 | define(`hanoi', `_hanoi(`$1', source, destination, auxilliary)') |
13 | |
14 | # traceon(`move', `_hanoi', `decr') |
15 | divert`'dnl |
Note:
See TracBrowser
for help on using the repository browser.