2013年10月31日木曜日

開発環境

C実践プログラミング 第3版 (Steve Oualline (著)、 望月 康司 (監訳) (翻訳)、谷口 功 (翻訳)、オライリー・ジャパン)のⅡ部(単純なプログラミング)の10章(Cプリプロセッサ)、10.1(#define文)、設問 10-1をHaskellで解いてみる。

その他参考書籍

設問 10-1.

コード(BBEdit)

Sample.hs

{-# OPTIONS -Wall -Werror #-}

main :: IO ()
main = putStrLn $ "The square of all the parts is " ++ 
                  show (allParts * allParts)

firstPart :: Int
firstPart = 7

lastPart :: Int
lastPart = 5

allParts :: Int
allParts = firstPart + lastPart

入出力結果(Terminal, runghc)

$ runghc Sample.hs
The square of all the parts is 144
$

0 コメント:

コメントを投稿