I'm struggling getting an answer to this:
Define a function functionWF
and functionPath
that takes an FsTree and returns a boolean that check whether the given tree is well-formed as a filesystem and whether the path (represented as a list of strings) is well-formed.
A well-formed filesystem cannot have identical paths leading to different nodes in the tree.
A well-formed path cannot contain nodes with empty names.
bellow a the type FsTree = Node of (string * FsTree) list
and bellow is an example of a FsTree :
fsT = [Node ("f1", [Node ("f2", [])]); [Node ("f3", [])]]
A
Node
is ill-formed if it contains more than one element with the same name, or if that is the case for any of the subtrees that it contains. Specifically,Node []
is well-formed. Those concepts can be the cases the recursive functionfunctionWF
:where
allElementsUnique
is a function that ensures that there are no duplicate elements in a list.I don't understand what you mean that
functionPath
should do.PS. Your example of an
FsTree
is not valid, it should haveNode
outside of the list: