这段代码有什么问题?我无法理解我在Seq.Map中做了什么错误。 以下是错误消息:类型“单元”不与类型兼容“SEQ <‘一>’
let getPathToLibFile value =
let regex = new Regex("\"(?<data>[^<]*)\"")
let matches = regex.Match(value)
matches.Value
let importAllLibs (lines:string[]) =
lines
|> Seq.filter isImportLine
|> Seq.iter (printfn "Libs found: %s")
|> Seq.map getPathToLibFile // error in this line
|> Seq.iter (printfn "Path to libs: %s")
是否有任何Seq.Map可理解例子?
PS例来自维基(它的工作原理):
(* Fibonacci Number formula *)
let rec fib n =
match n with
| 0 | 1 -> n
| _ -> fib (n - 1) + fib (n - 2)
(* Print even fibs *)
[1 .. 10]
|> List.map fib
|> List.filter (fun n -> (n % 2) = 0)
|> printlist
我怀疑是一样的;) – Carsten
@Coenoen:'reportLib'函数看起来好吗?这是我很担心的一点:) –
reportLib可能想成为一种方法而不是一种功能。对于给定的输入,它不会执行一次以上。但这可能会或可能不是原始海报的问题。 – Rangoric