# Binary tree error

**URL:** <https://discuss.ocaml.org/t/binary-tree-error/961>\
**Category:** Learning\
**Created:** [October 15, 2017, 9:53am UTC](https://discuss.ocaml.org/t/binary-tree-error/961 "2017-10-15T09:53:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ranamustafa](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@ranamustafa](https://discuss.ocaml.org/u/ranamustafa)\
**Post date:** [October 15, 2017, 9:53am UTC](https://discuss.ocaml.org/t/binary-tree-error/961/1 "2017-10-15T09:53:19Z")

</div>

Hi, i have this code that is use to construct binary tree where f is function and the f(f) mean that the result of f apply it second time to f, but the compiler its said their is error in f (f)

type 'a tree= |Leaf of 'a| Node of 'a tree \* 'a tree  
let rec build n x f = match n with  
|0-\>Leaf f x  
|\_-\>Node (build (n-1) x f,build (n-1) x (f(f)));;

---

<div class="post-metadata">

**Author:** ![vrotaru](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/vrotaru/32/39_2.png) [@vrotaru](https://discuss.ocaml.org/u/vrotaru)\
**Post date:** [October 15, 2017, 11:38am UTC](https://discuss.ocaml.org/t/binary-tree-error/961/2 "2017-10-15T11:38:42Z")

</div>

I can only agree with the compiler. Try replacing `(f(f))` with

```auto
(fun x -> f (f x))

```
