開発環境
- OS X Mavericks - Apple(OS)
- BBEdit - Bare Bones Software, Inc., Emacs (Text Editor)
- Haskell (純粋関数型プログラミング言語)
- GHC (The Glasgow Haskell Compiler) (処理系)
- The Haskell Platform (インストール方法、モジュール等)
C実践プログラミング 第3版 (Steve Oualline (著)、 望月 康司 (監訳) (翻訳)、谷口 功 (翻訳)、オライリー・ジャパン)のⅡ部(単純なプログラミング)の9章(変数スコープおよび関数)、9.4(構造かプログラミング)、9.5(再帰)、9.7(プログラミング実習)、実習 9-4をHaskellで解いてみる。
その他参考書籍
- プログラミングHaskell (オーム社) Graham Hutton(著) 山本 和彦(翻訳)
- Real World Haskell―実戦で学ぶ関数型言語プログラミング (オライリージャパン) Bryan O'Sullivan John Goerzen Don Stewart(著) 山下 伸夫 伊東 勝利 株式会社タイムインターメディア(翻訳)
9-4.
コード(BBEdit)
Sample.hs
{-# OPTIONS -Wall -Werror #-} import qualified Data.Char as Char main :: IO () main = mapM_ putStrLn $ map (\x -> x ++ ':':' ':(show $ hashCode x)) strings strings :: [String] strings = ["python", "c", "scheme", "dart", "haskell"] hashCode :: String -> Int hashCode = foldr (\x -> (+Char.ord x)) 0
入出力結果(Terminal, runghc)
$ runghc Sample.hs python: 674 c: 99 scheme: 629 dart: 427 haskell: 740 $
0 コメント:
コメントを投稿