F#列出文件夹和文件

时间:2018-12-10 01:13:32

标签: list file f# directory names

我必须编写一个名为“ find”的函数,在其中我可以输入一个Name。该功能必须搜索具有给定名称的文件或文件夹,并必须返回列表中的文件或文件夹。

这里有一个示例,说明:

find "Hallo" hallo = []
find "Hallo.txt" hallo = [["Hallo.txt"]]
find "Hallo.txt" dokumente = [["Dokumente"; "Hallo.txt"]]
find "Hallo.txt" (Folder ("Test", [hallo; dokumente ])) =
[["Test"; "Hallo.txt"]; ["Test"; "Dokumente"; "Hallo.txt"]]

那是我到目前为止尝试过的:

type Node =
    | File   of string * Nat          
    | Folder of string * (Node list)

let rec find (name: string) (root: Node): string list list =
        match root with
        | File (N,G)  ->if N=name then [[N]] else find(name)(root)
        | Folder(N,G) ->if N=name then [[N]] else find(name)(root)

1 个答案:

答案 0 :(得分:-1)

.menu {display: none; /* Hide on Desktop */}

@media (min-width: 600px) {
   .menu {display: block; /* Show on Mobile */}
}