我是 ocaml 的新手,并且已经定义了一个类型。
type options =
| Rock
| Paper
| Scissors
我还想定义一个选项列表。这就是我尝试的方式
type opts = list options;
当我尝试将选项的文字列表传递给函数时,Merlin 给了我这个错误
有任何想法吗?顺便说一句,尽管我认为这并不重要,但我正在专门使用 ReasonML。
这是翻译回 ocaml 的整个函数。
let compGuess () =
let rec aux opts k =
match opts with
| [] -> [Rock]
| x::[] -> x
| h::t -> (match k = 1 with | true -> h | false -> aux t (k - 1)) in
aux [Rock; Paper; Scissors] ((Random.int 3) + 1)