【发布时间】:2015-06-28 14:40:54
【问题描述】:
所以我已经定义了自己的类型:
type test = Empty
| Int of int
| Str of string
| List of test list;;
我正在尝试遍历列表并评估每个头部,但我似乎无法使其工作。
type evalRes = Next /* | other matches just ignore this. It's needed for something else */;;
let rec eval (test:test) : (evalRes) = match test with
| Int i -> /* do int stuff */; Next
| Str s -> /* string stuff */; Next
| List(stmt1::tail) -> eval stmt1;;
我知道这只会评估第一个。我怎样才能得到它来评估列表的其余部分?而且我的类型测试会有更多的case来匹配,这只是一个基本的测试。
【问题讨论】: