F# on Mac: Syntax Error on Inner Function

Posted by JBristow on Stack Overflow See other posts from Stack Overflow or by JBristow
Published on 2010-04-12T17:55:05Z Indexed on 2010/04/12 18:03 UTC
Read the original article Hit count: 489

Filed under:
|

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'.

© Stack Overflow or respective owner

Related posts about F#

Related posts about mac