下記関数
$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
More than 5 years have passed since last update.
下記関数
$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
Register as a new user and use Qiita more conveniently