「48時間でSchemeを書こう/練習問題の解答」の版間の差分

削除された内容 追加された内容
en:Write Yourself a Scheme in 48 Hours/Answers to Exercises (08:17, 6 July 2010 UTC) をインポート
 
最初の一歩を和訳
1 行
= 最初の一歩 =
=Chapter 1=
 
== 二つのコマンドライン引数を取る ==
===Exercise 1===
<syntaxhighlight lang="haskell">
import System
 
main :: IO ()
main = do args <- getArgs
putStrLn ( "Hello , " ++ args !! 0 ++ " " ++ args !! 1)
</syntaxhighlight>
 
== コマンドライン引数と簡単な計算 ==
===Exercise 2===
<syntaxhighlight lang="haskell">
import System
 
main :: IO ()
main = do args <- getArgs
print ($ (read $ args !! 0) + (read $ args !! 1))
</syntaxhighlight>
 
<code>$</code>演算子によって括弧の数を減らしています。最後の行は<code>$</code>を使わずに<code>print ((read (args !! 0)) + (read $ args !! 1))</code>とも書けます。
The <code>$</code> operator reduces the number of parentheses needed here. Alternatively you could write the function applications as <code>read (args!!0)</code>.
 
== 名前のエコー ==
===Exercise 3===
<syntaxhighlight lang="haskell">
import System
 
main :: IO ()
main = do putStrLn "What do they call thee at homeお名前は?"
name <- getLine
putStrLn ("Ey up$ "あなたの名前は" ++ name) ++ "ですね!"
</syntaxhighlight>
 
=Chapter 2=