【发布时间】:2015-06-15 03:25:06
【问题描述】:
我是编程新手,F# 是我的第一语言。
以下是我的代码的相关部分:
let rec splitArrayIntoGroups (inputArray: string[]) (groupSize: int) (hashSetOfGroups: HashSet<string[]>)=
let startIndex = 0
let endIndex = groupSize - 1
let group = inputArray.[startIndex .. endIndex]
let nextInputArray = inputArray.[groupSize .. inputArray.Length - 1]
hashSetOfGroups.Add(group) |> ignore
splitArrayIntoGroups nextInputArray groupSize hashSetOfGroups
let hashSetOfGroups = new HashSet<string[]>()
splitArrayIntoGroups urlArray 10 hashSetOfGroups
urlArray 是一个包含近 3200 个 URL 的数组。
当我尝试在 F# 交互中运行代码时,我收到以下错误消息:
Program.fs(119,1):错误 FS0030:值限制。 “它”的价值 被推断为具有泛型类型 val it : '_a 将 'it' 定义为一个简单的数据项,使其成为具有显式参数的函数,或者,如果您不打算让它 是通用的,添加一个类型注释。
出了什么问题,我应该做出什么改变?
【问题讨论】:
-
splitArrayIntoGroups函数应该返回什么值?如果它只是产生副作用,它应该返回单位,但在这种情况下,我想它不会正常终止。
标签: f#