OCaml beginner needs help: What is wrong?

Posted by Junz on Stack Overflow See other posts from Stack Overflow or by Junz
Published on 2010-03-17T21:45:22Z Indexed on 2010/03/17 21:51 UTC
Read the original article Hit count: 644

Filed under:
|

Code:

let rec get_val (x, n) = match x with

    [] -> -1

  | if (n=0) then (h::_) -> h 


    else (_::t) -> get_val(t, n-1)

;;

Error message:

Characters 55-57:

    | if (n=0) then (h::_) -> h 

      ^^

Error: Syntax error

© Stack Overflow or respective owner

Related posts about ocaml

Related posts about beginner