0
在子集中,我在紅色的波浪曲線中得到以下錯誤。
Type mismatch. Expecting a Range -> Choice but given a Range * Range -> Choice
F#將活動模式與擴展元組匹配
是否有某種類型的註釋我可以添加到SubSet匹配,所以我不必使用fst和snd?如果不是,是否有意支持這種語法?
type Range = {min : int64; max : int64}
let (|Before|After|BeforeOverlap|AfterOverlap|SuperSet|SubSet|) (x, y) =
if x.min > y.max then After
elif x.min >= y.min then
if x.max <= y.max then SubSet
else AfterOverlap
elif x.max < y.min then Before
elif x.max <= y.max then BeforeOverlap
else SuperSet
let useOldx x xe ye =()
let diff (xe:IEnumerator<Range>) (ye:IEnumerator<Range>) =
match xe.Current, ye.Current with
| After as tuple ->()
| Before as t -> if xe.MoveNext() then useOldx (fst t) xe ye
| SuperSet as t ->
let x, y = t
if xe.MoveNext() then useOldx x xe ye
| SubSet as x, y -> if xe.MoveNext() then useOldx x xe ye
| _ ->()
真棒,謝謝! – gradbot
活動模式就是這樣一個簡單的概念,但它確實有助於將複雜的問題分解爲逐漸變小的部分,並且它是可讀的! – gradbot