He leído todas las pistas sobre la restricción de valores en F #, pero todavía no lo entiendo. Tengo el siguiente código:Restricción del valor F #
type tree<'a> =
| Nil
| Node of (tree<'a> * 'a * tree<'a>)
let rec flatten = function
| Nil -> []
| Node (Nil, b, Nil) -> [b]
| Node (l, h, p) -> List.concat [(flatten l);[h];(flatten p)]
y el compilador mostrará un error:
error FS0030: Value restriction. The value 'it' has been inferred to have generic type
val it : '_a list
Either define 'it' as a simple data term, make it a function with explicit arguments or, if you do not intend for it to be generic, add a type annotation.
¿Puede alguien ayudarme? Muchas gracias;)
¿Puede proporcionar el llamado de código aplanado? Puedo compilar y ejecutar esta muestra muy bien – JaredPar
pero cuando llamo aplanar Nill ;; Hay un problema. – 877