0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

中古ノート、買ってみた。 その86

Last updated at Posted at 2025-11-25

概要

中古ノート買ってみた。
wsl1のubuntu18.04にgforth入れてみた。
チュートリアルを作ってみた。

TUTORIAL 14

ハノイの塔

Gforth 0.7.3, Copyright (C) 1995-2008 Free Software Foundation, Inc.
Gforth comes with ABSOLUTELY NO WARRANTY; for details type `license'
Type `bye' to exit
variable cnt  ok
: hanoi-print cr 2dup . ." -> " . ;  ok
: hanoi-impl dup >r 0> if rot swap r@ 1- recurse cnt @ 1+ cnt ! hanoi-print rot r@ 1- recurse swap then r> drop ;  ok
: hanoi 0 cnt ! hanoi-impl drop drop drop cr ." count: " cnt @ . cr ;  ok
1 2 3 3 hanoi
3 -> 1
3 -> 2
1 -> 2
3 -> 1
2 -> 3
2 -> 1
3 -> 1
count: 7
 ok
bye

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?