开发者

List.map fsi is telling ok, but can't build

Why this piece of code is working on my fsi, but can't build the project? I am using vs2010 and F# 2.0 ...Any ideas that I am missing something?

let arg = [@"C:\Temp\bin"; @"C:\temp\xml"]
arg|> List.map(fun (s) -> printfn "%s" s)           

getting the error tell开发者_运维百科ing that it was expecting int, how?

Error 1 
Type mismatch. Expecting a string list -> int but given a string list -> 'a list  
The type 'int' does not match the type ''a list'    
C:\Users\Ebru\Documents\Visual Studio 2010\Projects\WinFind\WinFind\Program.fs


I'm guessing you actually wrote

[<EntryPoint>]
let Main(args) =
    let arg = [@"C:\Temp\bin"; @"C:\temp\xml"] 
    arg|> List.map(fun (s) -> printfn "%s" s)  

and an EntryPoint method (e.g. Main()) must return an int.


this snippet compiles on my machine, but the mapping seems weird. I think you really what to do this:

let arg = [@"C:\Temp\bin"; @"C:\temp\xml"]
arg|> List.iter (fun s -> printfn "%s" s)

which is the same as:

let arg = [@"C:\Temp\bin"; @"C:\temp\xml"]
arg|> List.iter (printfn "%s")

Regards, forki

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜