From 4044f88cfae7a8c3b7523a7d2380bbcacc85ebcb Mon Sep 17 00:00:00 2001 From: crc Date: Sun, 22 Oct 2017 17:45:28 +0000 Subject: [PATCH] towers of hanoi; better variable naming FossilOrigin-Name: dcbc4dc52e45f686490ce8d4c4e9b5cd9ffbbf2fad7e76ab5a2faff5023fa498 --- example/hanoi.forth | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/example/hanoi.forth b/example/hanoi.forth index a40eb09..52ee819 100644 --- a/example/hanoi.forth +++ b/example/hanoi.forth @@ -1,20 +1,20 @@ ~~~ -'a var -'b var -'c var -'n var +'Num var +'From var +'To var +'Via var -:vars !c !b !a !n ; +:set-vars !Via !To !From !Num ; :hanoi (num,from,to,via-) - vars - @n n:-zero? + set-vars + @Num n:-zero? [ - @n @a @b @c - @n n:dec @a @c @b hanoi - vars - @b @a '\nMove_a_ring_from_%n_to_%n s:with-format puts - @n n:dec @c @b @a hanoi + @Num @From @To @Via + @Num n:dec @From @Via @To hanoi + set-vars + @To @From '\nMove_a_ring_from_%n_to_%n s:with-format puts + @Num n:dec @Via @To @From hanoi ] if ; -#5 #1 #3 #2 hanoi nl +#3 #1 #3 #2 hanoi nl ~~~