我有以下代码:
函数numbersDictionary
尝试创建关联数组,takeVal
尝试获取相应键的值。
let numbersDictionary =
let d = [('I', 1); ('V', 5); ('X', 10); ('L', 50); ('C', 100); ('D', 500); ('M', 1000)] |> Map.ofList
d
let takeVal par =
match par with
| Some(v) -> v
| None -> 0
let rec evaluate( numbersInchar:List<char>)=
match numbersInchar with
|[] -> []
|head::tail -> takeVal (numbersDictionary.TryFind head)::evaluate tail
在匹配|[] -> []
的第一行,我遇到了以下的错误:
This expression was expected to have type list<char> but here has type 'a list
我既不能解释这个问题也不能解决它。
请帮帮我。
答案 0 :(得分:0)
>>> a,b = zip(*[i.split('.') for i in d])
>>> a
('a1', 'a2', 'a3')
>>> b
('b1', 'b2', 'b3')