学習ログ
Local Variables
-- foo.hs foo x = let a = 0 b = 1 c = 2 d = map (* 2) [1..] in if x >= 3 then d else [a, b, c]
>:load foo.hs ... > foo 2 [0,1,2] > foo 3 [0,1,2] [2,4,6,8,10,12,14,16,18,20,.....
-- bar.hs bar x = if x >= 3 then d else [a, b, c] where a = 0 b = 1 c = 2 d = map (* 2) [1..]
whereを使う方が、本文の式を強調できる。スペースの幅に注意。
Real World Haskell: Code You Can Believe In
- 作者: Bryan O'Sullivan,John Goerzen,Donald Bruce Stewart
- 出版社/メーカー: O'Reilly Media
- 発売日: 2008/12/05
- メディア: ペーパーバック
- 購入: 2人 クリック: 78回
- この商品を含むブログ (40件) を見る