这是我到目前为止有:F#匹配问题
type u = {str : string} //some type that has some property str (for simplicity, only one)
type du=
| A of u
| B of u // some discriminated union that carries u with it
然后,带我去的杜的序列我做distinctBy并做不同的是海峡财产。 最好我能想出是这样的:
Seq.distinctBy (fun d -> match d with (A u|B u) -> u.str)
代码工作,但我不喜欢以匹配识别联合a和b,愿与东西来取代了比赛。
问题是,是什么? :)
编辑:
在我的情况下,与识别联合的B就始终贯彻同样的U型与他们,一个解决方案是摆脱杜,并添加它的字符串形式输入u和简化这整个混乱,但我想现在保持这种方式,因为我打算做的比赛,这样的a和b ...
我相信歧视的工会案件必须是大写 - 不知道为什么这是。 – Jimmy 2011-02-17 22:53:45
@Jimmy,你说的对,我会编辑它,谢谢 – Alex 2011-02-18 15:47:10