Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type ntree = Leaf of string | Ntr of string * ntree list;;
- let ntr1 = Ntr("/", [Ntr("etc", [Leaf("fstab");Leaf("mtab")]);Leaf(".empty")]);;
- let find_path ntr l1 =
- let rec fp' ctl lc =
- match lc with
- [] -> true
- | x::xs ->
- match ctl with
- Ntr(path, nls)::ys ->
- if (x = path) then
- fp' nls xs (* go down the tree then! *)
- else
- fp' ys lc (* try to match at the same tree level *)
- | Leaf(path)::ys ->
- if (x = path) then
- fp' ys xs (* go down the path *)
- else
- fp' ys lc (* search at the same level *)
- | _ -> false
- in
- fp' [ntr] l1;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement