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
私はF#: Filter items found in one list from another listに従っていますが、私が見ている解決策はどちらもコンパイルされていないため、問題には適用できませんでした。 List.Containsが存在せず(参照がありません)、ListA - ListBもコンパイルされません。無効なドライブ文字のリストを取得する
したがって、シーケンスを減算することはできますか? C#でセットに最も近いものは何ですか? – Maslow
@Maslow: 'System.Collections.Generic.HashSet <>'であり、LINQには多くのset-like操作があります。 – ildjarn
C#では次のことができます: 'var unused = new HashSet(allLetters); unused.ExceptWith(driveLetters); ' –
Daniel