Binary tree error

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)));;

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

(fun x -> f (f x))