Created
January 30, 2013 07:40
-
-
Save akanehara/4671481 to your computer and use it in GitHub Desktop.
すごいHaskell読書会 in 大阪 #4 第6章 「モジュール」持ち寄り練習問題
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- すごいHaskell読書会 in 大阪 #4 | |
-- 第6章 モジュール | |
-- 持ち寄り練習問題 @akanehara | |
-- このスクリプトでは、英語圏でよく冗談めいて使われる | |
-- 換字式暗号ROT13(http://ja.wikipedia.org/wiki/ROT13) | |
-- の動作を確かめて遊んでいます。 | |
-- ところが、ここで使われているモジュール Toys.Rot13 | |
-- はまだ実装されていません! | |
-- testRot13 が True を返すように、Toys.Rot13 を実装 | |
-- してあげてください。 | |
-- | |
-- testRot13 が期待する結果を直接返す(^^;)というひどい | |
-- 反則さえしなければ、実装方法は問いません。 | |
-- | |
-- ともかく、モジュールを作って使うという経験をしてみましょう! | |
import qualified Toy.Rot13 as Rot13 (encrypt) | |
testRot13 :: Bool | |
testRot13 = Rot13.encrypt chipher == plain -- 暗号文をさらにencryptすると平文に戻るはず | |
where plain = "Lern You a Haskell for Great Good!" -- 平文 | |
chipher = Rot13.encrypt plain -- 暗号文 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment