My code is very basic as I am pretty new to ocaml I am trying to call a function recursively but I am getting an unbound value error message on the name of the function
let count_help x a lst = match lst with
[] -> a
| (s,i)::t -> if s = x then count_help x a+1 t else count_help x a t
;;
let count_assoc lst x =
count_help x 0 lst
;;
The error is Unbound value count_help on the line that calls count_help inside of count_help
This code is simply suppose to count the number times an association appears for the given character x
You need to say
let rec count_help ...
to allow the name count_help to be used recursively within its definition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With