Hi

You mean that `nbf1 [ 1 ; 2 ; 9 ; 5 ; 7 ; 9 ] 9`

should give 1.

And `nbf1 [ 9 ; 2 ; 9 ; 5 ; 9 ; 8 ] 9`

should give 3.

With your code I see warning 8 (not exhaustive PM) and warning 11 (unused match case):

```
let nbf1 l x =
let rec nbf l x acc =
match l with
| [] -> acc
| a::b::t -> if a = x then nbf t x (acc + 1) else nbf t x acc
| a::b::[] -> if a = x then acc + 1 else acc in
nbf l x 0
```

Characters 37-169:

match l with

| [] -> acc

| a :: b :: t -> if a = x then nbf t x (acc + 1) else nbf t x acc

| a :: b :: [] -> if a = x then acc + 1 else acc

Warning 8: this pattern-matching is not exhaustive.

Here is an example of a value that is not matched:

_ :: []

Characters 127-135:

| a :: b :: [] -> if a = x then acc + 1 else acc

^^^^^^^^

Warning 11: this match case is unused.

Case 3 is case 2 with t = [], so it’s not a correct pattern-matching.

You should organize your match cases as follows:

empty list

list with one element

list with at least 2 elements with possibly empty tail:

```
let nbf1 l x =
let rec nbf l x acc =
match l with
| [] -> acc
| a::[] -> if a = x then acc + 1 else acc
| a::b::t -> if a = x then nbf t x (acc + 1) else nbf t x acc in
nbf l x 0
val nbf1 : 'a list -> 'a -> int = <fun>
```

```
# nbf1 [ 9 ; 2 ; 9 ; 5 ; 9 ; 8 ] 9
- : int = 3
```