今日もあやはお休み
ひきつづき
module Sample where
-
- タプル
func11 = (1,2)
func12 = (1,2,3,4,5)
func13 n (a,b,c,d,e) = case n of
0->a
1->b
2->c
3->d
5->e
-
- 型
func14 :: Int -> Int -> Int
func14 x y = x * y
-
- 引数の減った関数
- func14 1 2
- (func14 1) 2
今日はこの辺で
module Sample where
-
- 関数定義
foo x y = x + y
hoge = 2
-
- 分岐
- 引数パターンマッチング
boo 1 = "a"
boo 2 = "b"
func0 0 = 1
func0 n = n * func0(n-1)
-
- ガード
func1 a b |a && b == 1 = "0!"
|a = "1!"
|otherwise = "2!"
-
- if
func2 n = if n == 0
then "OK"
else "NG"
-
- case
func3 n = case n of
0->"a"
1->"b"
_->"c"
-
- 補助関数
- インデントに注意
- where
func4 a b = c + d
where
c = a * b
d = a * b
-
- 同let
func5 a b = let
c = a * b
d = a * b
in c + d
func6 a b = iter a 0
where
iter c d
|c < b = (d,c)
|otherwise = iter (c-b) (d+1)
func7 a b = a * b
f0 = \x->x + 1
func8 a = a + 1
func9 a b = a + b
func10 a = a - 1
つかれた
指輪をしていない指が軽くて淋しい。
■
xxx
創世記
なんで「われわれ」なんだろう?
「われわれに似るように、われわれのかたちに、人を造ろう。・・・」
一人じゃないの?