[Haskell] 『すごいHaskell たのしく学ぼう!』13.6節の演習

『すごいHaskell たのしく学ぼう!』の13.6節ではリストモナドによる非決定性計算を使ってチェスのナイトが3手で指定したマスに到達できるかを計算する関数が紹介された。 ghci> (6, 2) `canReachIn3` (6, 1) True のように始点と終点を指定すると到達の可否がかえってくる。 節尾の演習にどのように到達できるか教えてくれるようにせよとあったので書いてみる。 import Monad type KnightPos = (Int, Int) type KnightTrack = [KnightPos] moveKnight :: KnightTrack -> [KnightTrack] moveKnight ((c, r) : xs) = map addLog $ filter onBoard [(c+2,r-1), (c+2,r+1), Continue reading [Haskell] 『すごいHaskell たのしく学ぼう!』13.6節の演習


Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /usr/home/bugyo/public_html/b-log/wp-includes/category.php on line 383
Posted in コンピュータ | Leave a reply