Skip to content

Instantly share code, notes, and snippets.

Created January 4, 2014 18:42
Show Gist options
  • Save anonymous/8258894 to your computer and use it in GitHub Desktop.
Save anonymous/8258894 to your computer and use it in GitHub Desktop.
;; eval のテスト
(define g (game-master)) ; Game Master クラスのインスタンス g を定義。
class-vars-alist ; クラス変数の表示。phase の値に着目。
(interp g 'introduction #t) ; phase が 'introduction、入力値が #t の場合。
class-vars-alist
(interp g 'instruction #t) ; phase が 'instruction、入力値が #t の場合: その1。
class-vars-alist
(interp g 'instruction #t) ; phase が 'instruction、入力値が #t の場合: その2。
class-vars-alist
(interp g 'input-integer 100) ; phase が 'input-integer、入力値が 100 の場合。
class-vars-alist
(interp g 'next-day #f) ; phase が 'next-day、入力値が #f の場合。
class-vars-alist
(interp g 'test #f) ; phase が 'test、入力値が #f の場合。
;; テストの実行結果
'((game-master ()) ; クラス変数はParser Classのみ持ってる事が分かる。値はphase。
(environment ())
(weather ())
(tofu ())
(computer ())
(player ())
(parser ((phase . introduction))))
'introduction ; 返り値はシンボル 'introduction と #f の二つ。
#f
'((parser ((phase . instruction))) ; phase の値が 'instruction に変更されている。
(game-master ())
(environment ())
(weather ())
(tofu ())
(computer ())
(player ()))
'instruction ; 返り値はシンボル 'instruction と #f の二つ。
#f
'((parser ((phase . instruction)))
(game-master ())
(environment ())
(weather ())
(tofu ())
(computer ())
(player ()))
'show-data ; 二回目の呼び出しでは返り値はシンボル 'show-data と クロージャ の二つに変わってる。
#<procedure:...erInIscandar.rkt:47:9> ; (この為だけにstrange-flagがある)
'((parser ((phase . input-integer))) ; phase の値が 'input-integer に変更されている。
(game-master ())
(environment ())
(weather ())
(tofu ())
(computer ())
(player ()))
'opponent-turn ; 返り値はシンボル 'opponent-turn と125と言う整数。
125 ; この125はevalで評価された値で、コンピュータが作ろうとするトーフの数。
'((parser ((phase . next-day))) ; phase の値が 'next-day に変更されている。
(game-master ())
(environment ())
(weather ())
(tofu ())
(computer ())
(player ()))
'next-day ; 返り値は 'next-day と言うシンボルと 'cloudy と言うシンボルの二つ。
'cloudy ; 'cloudy も Evalの評価結果で、「次の日の天気」を確率計算した結果。
'((parser ((phase . test))) ; phase の値が 'test に変更されている。
(game-master ())
(environment ())
(weather ())
(tofu ())
(computer ())
(player ()))
'show-data ; 返り値は 'show-data と言うシンボルとクロージャ。
#<procedure:...erInIscandar.rkt:47:9> ; ここでゲームの二回目のプロセスへと戻る。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment