Sunday, 15 September 2013

finding the first occurence in a list

finding the first occurence in a list

I want to find the first occurence of a digit in a list :
let pos_list = function (list , x) ->
let rec pos = function
|([] , x , i) -> i
|([y] , x , i) -> if y == x then i
|(s::t , x , i) -> if s == x then i else pos(t , x , i + 1) in
pos(list , x , 0) ;;
but the compiler complain that the expression is a "uint" type , and was
used instead with a "int" type .

No comments:

Post a Comment