開発環境
- macOS Sierra - Apple (OS)
- Emacs (Text Editor)
- Haskell (プログラミング言語)
- Haskell Platform(ghci)(処理系)
関数プログラミング入門(Richard Bird (著)、山下伸夫 (翻訳)、オーム社)の第1章(基本概念)、1.7(仕様)、練習問題1.7.1を取り組んでみる。
練習問題1.7.1
コード(Emacs)
-- 1.7.1 square :: (Num a) => a -> a square a = a * a increase :: Integer -> Integer increase x = (square x) + 1
入出力結果(Terminal, ghci)
$ ghci sample7.hs GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( sample7.hs, interpreted ) Ok, modules loaded: Main. *Main> increase 0 1 *Main> square 0 0 *Main> increase 1 2 *Main> square 1 1 *Main> increase 10 101 *Main> square 10 100 *Main> :q Leaving GHCi. $
0 コメント:
コメントを投稿