Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type toDo = {id: string; indent: int; descendants: toDo list}
- let rec children x ys accumulated =
- match ys with
- | [] -> (accumulated, [])
- | y::rest ->
- match (y.indent - x.indent) with
- | 1 ->
- let descendants, _ = children y rest List.empty<toDo>
- let filledChild = {y with descendants = descendants |> List.sortBy (fun x -> x.id)}
- filledChild::accumulated |> children x rest
- | diff when diff < 1 -> (accumulated |> List.sortBy(fun x -> x.id), y::rest)
- | _ -> children x rest accumulated
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement