我正在翻译 Little Mler 的一个对这种数据类型进行操作的函数
type sexp<'T> =
An_Atom of 'T
| A_slist of slist<'T>
and
slist<'T> =
Empty
| Scons of sexp<'T> * slist<'T>
功能
// occurs_in_slist : aVal slist -> int
// checks the number of occurrence for aVal in slist
let rec occurs_in_slist =
function
_, Empty-> 0
| (aVal : 'T), Scons(aSexp, (aSlist : 'T)) ->
occurs_in_sexp (aVal, aSexp) + occurs_in_slist (aVal, aSlist)
and
aVal, An_Atom (bVal) -> if (aVal = bVal) then 1 else 0
| (aVal , A_slist(aSlist)) -> occurs_in_slist (aval, aSlist)
但是,第二个函数出现此错误
error FS0010: Unexpected symbol '->' in binding. Expected '=' or other token.