Weitere ähnliche Inhalte
Mehr von Eita Sugimoto (10)
ラムダ計算入門
- 18. 嬉しいです
• f(x, y) = x
• … x と y の両方を渡す必要がある
• f(x)(y) = x
• … x だけ渡す、という操作が可能
• この操作を部分適用と言う
- 19. ついでに
• λx. (λy. x) は λx. λy. x と表せる
• どこがどの関数か自明
• λx. λy. x は λxy. x と表せる
• ただの省略記法
- 23. Sコンビネータ
• λx y z. x z (y z)
• Sharing combinator
• z をシェアする
• S (λa. M) (λb. N) = λz. M N
• ただし M = M[a:=z], N = N[b:=z]
- 28. 具体的には
• 0 := λs z. z
• 1 := λs z. s z
• 2 := λs z. s (s z)
• 3 := λs z. s (s (s z))
• ...
- 30. Tuple
• (t1, t2) := λx. x t1 t2
• fst := λt. t (λf s. f)
• snd := λt. t (λf s. s)
- 33. List (Church)
• [x,y,z]
• =λc n. c x(λc n. c y(λc n. c z n))
• cons が foldr 的に振る舞う!
• foldr = λn c l. l c n
• tail = λl. l (λx xs. xs) Nil
- 35. 自然数 (Scott)
• 0 := λz s. z
• 1 := λz s. s 0
• 2 := λz s. s 1
• 3 := λz s. s 2
• ...
Hinweis der Redaktion
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n