Is it possible to have a Ocaml function that accepts only integer lists?

Posted by Sam on Stack Overflow See other posts from Stack Overflow or by Sam
Published on 2010-04-12T01:24:16Z Indexed on 2010/04/12 1:33 UTC
Read the original article Hit count: 330

Filed under:
|
|

I'm writing a recursive function in Ocaml that's supposed to count the number of items in an integer list (Yes I know there's a List.length function but I'm trying to do it myself). However the Ocaml compiler/interpreter forces me to use alpha list all the time.

So is it wrong to say that, when a function accepts a list as a parameter, the type of that list must always be alpha? Thanks

EDIT: the reason why it's inconvenient for me to use alpha lists is because i can't compare the head of the alpha list with an integer value due to type-matching complaints

© Stack Overflow or respective owner

Related posts about ocaml

Related posts about caml