F# on Mac: Syntax Error on Inner Function
- by JBristow
The following code:
exception NoElements of string
let nth(k, list) =
let rec loop count list =
match list with
| head :: _ when count = k -> head
| _ :: tail when count <> k -> loop (count+1) tail
| [] -> raise (NoElements("No Elements"))
loop 0 list
;;
printfn "%A" (nth(2, [1, 1, 2, 3, 5, 8]))
Produces the following errors when compiling on a mac, but not in Visual Studio 2010:
nth.fs(10,0): error FS0191: syntax error.
nth.fs(4,4): error FS0191: no matching 'in' found for this 'let'.