Can someone check my sanity here please. Given this simple function:
let filterOut item l =
l |> List.filter (fun t -> not (t = item))
let f =
["1";"2";"3"]
|> filterOut "3"
Evaluating the above in FSI produces the following:
Xamarin Studio with mono 4.0.3 on Mac OS X
val f : string list = ["1"]
Visual Studio 2013
val f : string list = ["1"; "2"]
If the input is a list of ints or chars - then it works as expected and both platforms produce identical results. Also if I specify filterOut to only work with strings it correctly produces identical values. Like so:
let filterOut item l:list<string> =
l |> List.filter (fun t -> not (t = item))
Even the following code with XS on OS X:
let filterOut item l =
l |> List.filter (fun t -> not (t = item))
let f =
["1";"2";"3"]
|> filterOut "foobar"
outputs:
val f : string list = ["1"]
I have compared the IL between the XS and VS compiled code and they appear identical. So it seems like a runtime discrepancy. If there something going on here with List.Filter and generic comparison with strings on Mono?
EDIT: If I add "inline" to the filterOut function I also get correct results on both platforms (expected output on OS X). Again it seems something is wrong with the generic comparer on the Mono runtime.
(1 month later) Tested on latest Mono 4.2.0 and now works as expected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With