SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
56.
Boost.Lambdaでのラムダ式
• 何故かできてしまう
int main()
{
using namespace boost::lambda;
auto f = _1; // ¥x -> x
cout<<f(1)<<endl; // -> 1
cout<<f(3.14)<<endl; // -> 3.14
}
• fの型は何なのか?
– forall a . a -> a をどうやって表現している?
63.
カリー化の旨み
• 純粋関数的に状態を持ちまわるというのが
とてもやりやすくなる
cnt acc i = (acc, cnt (acc+i))
let a = cnt 0 in
let (v, b) = a 1 in –- v = 0
let (w, c) = b 2 in –- w = 1
let (x, d) = c 3 in –- x = 3
...
• オブジェクト vs 関数
• 関数プログラミングでは、次の状態として
関数を返すことがよくある(e.g. Iteratee)