Ho letto tutte le impronte sulla restrizione del valore in F #, ma ancora non lo capisco. Ho il seguente codice:Limitazione valore 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)]
e il compilatore mostrare un errore:
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.
Qualcuno mi può aiutare? Grazie mille;)
È possibile fornire un appiattimento del codice? Posso compilare ed eseguire questo esempio semplicemente – JaredPar
ma quando chiamo Nill appiattito ;; c'è un problema. – 877