LoginSignup
1
0

More than 5 years have passed since last update.

[WIP]javascript 関数合成

Last updated at Posted at 2015-01-28

下記関数
$f(x) = x +3$
$g(x) = x * 2$
から
関数
$h(x) = f(g(x)) = (x * 2) + 3 $
を作る方法

>function(x){return x + 3}
>function(x){return x * 2}
//関数を合成するための関数composeを定義
>function compose(f,g){return function(x){return f(g(x))}}
>h = compose(f,g)
>h(2)
< 7
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0