這是我到目前爲止有: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