I have a recursive function working on a list, the function contains a loop where itself is called, and ends up with another function `g`. Its structure is similar as follows, to simplify the issue, we can assume that `l` is always a list without duplicate elements.

```
let rec f l = function
  | [] -> g ()
  | _ ->
      List.fold_left
        (fun acc x ->
           let lr = List.filter (fun a -> (a <> x)) l in
           acc + (f lr))
        1 l

```

I am not sure how to express the complexity of this function, with `List.length l` and the complexity of `g`.

I think it is proportional to the complexity of `g` and the **factorial** of `List.length l`, could anyone confirm?