This is a beginner question, as I'm still figuring out what the F# compiler errors mean and how to fix them.
I have the following F# code - and can't see why it will not work. It is based off the solution found here: F#: Recursive collect and filter over N-ary Tree
module TreeProblem_Solution1 =
type TreeNode =
| N of int * TreeNode list
let rec filterTree (t : TreeNode) (predicate : int -> bool) =
()
let test =
TreeNode(1,[TreeNode(2,[])])
The error i get is under TreeNode(1,[TreeNode(2,[])]). I don't understand why this is causing a problem, when the nested TreeNode usage correctly displays the type and doesn't have any constructor problems, and I can also use this type as a method parameter.
Hopefully someone out there can shed some light on this, as I'm missing some vital insight.