I defined the active pattern "Expression" as follows:
let (|Expression|_|) expression _ = Some(expression)
Now I'm trying to use it in this way:
match () with
| Expression((totalWidth - wLeft - wRight) / (float model.Columns.Count - 0.5)) cw
when cw <= wLeft * 4. && cw <= wRight * 4. ->
cw
| Expression((totalWidth - wLeft) / (float model.Columns.Count - .25)) cw
when cw <= wLeft * 4. && cw > wRight * 4. ->
cw
| Expression((totalWidth - wRight) / (float model.Columns.Count - .25)) cw
when cw > wLeft * 4. && cw <= wRight * 4. ->
cw
| Expression(totalWidth / float model.Columns.Count) cw
when cw > wLeft * 4. && cw > wRight * 4. ->
cw
| _ -> System.InvalidProgramException() |> raise
But this results in "error FS0010: Unexpected symbol '-' in pattern". Is that fixable?
What am I trying to do is to write clearly a solution to the following equation:
max(wl - cw * .25, 0) + max(wr - cw * .25) + cw * columnCount = ActualWidth
where cw is the only variable.
Can you suggest any better way?
| MyActive (myfuna>>myfunb) x -> ...
we can only do letmyfun = myfuna>>myfunb ... | MyActive myfun x -> ...
– Untuck