Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
F# 获取无效驱动器号的列表_F#_Sequences - Fatal编程技术网

F# 获取无效驱动器号的列表

F# 获取无效驱动器号的列表,f#,sequences,F#,Sequences,我遵循了,但无法将其应用于我的问题,因为我看到的两个解决方案似乎都没有编译。List.Contains不存在(缺少引用?),ListA-ListB也不编译。您的第一个错误是混合了char和string,最好从char开始: let private GetDrives = seq{ let all=System.IO.DriveInfo.GetDrives() for d in all do //if(d.IsReady && d.DriveType=System.IO.D

我遵循了,但无法将其应用于我的问题,因为我看到的两个解决方案似乎都没有编译。List.Contains不存在(缺少引用?),ListA-ListB也不编译。

您的第一个错误是混合了
char
string
,最好从
char
开始:

let private GetDrives = seq{
let all=System.IO.DriveInfo.GetDrives()
for d in all do
    //if(d.IsReady && d.DriveType=System.IO.DriveType.Fixed) then
        yield d
}

let valid={'A'..'Z'}
let rec SearchRegistryForInvalidDrive (start:RegistryKey) = seq{
    let validDrives=GetDrives |> Seq.map (fun x -> x.Name.Substring(0,1))
    let invalidDrives= Seq.toList validDrives |> List.filter(fun x-> not (List.exists2 x b)) //(List.exists is the wrong method I think, but it doesn't compile
open System.IO
let driveLetters = set [ for d in DriveInfo.GetDrives() -> d.Name.[0] ]
let unused = set ['A'..'Z'] - driveLetters
现在,无效驱动器号是指
all
中但不在
validAddress
中的驱动器号:

let all = {'A'..'Z'}
let validDrives = GetDrives |> Seq.map (fun x -> x.Name.[0])

您的第一个错误是混合了
char
string
,最好从
char
开始:

open System.IO
let driveLetters = set [ for d in DriveInfo.GetDrives() -> d.Name.[0] ]
let unused = set ['A'..'Z'] - driveLetters
现在,无效驱动器号是指
all
中但不在
validAddress
中的驱动器号:

let all = {'A'..'Z'}
let validDrives = GetDrives |> Seq.map (fun x -> x.Name.[0])

所以你可以减去集合,但不能减去序列?在c#中最接近集合的是什么?@Maslow:
System.Collections.Generic.HashSet
,LINQ有许多类似集合的操作;未使用。除(大写字母)外所以你可以减去集合,但不能减去序列?在c#中最接近集合的是什么?@Maslow:
System.Collections.Generic.HashSet
,LINQ有许多类似集合的操作;未使用。除(大写字母)外