I am porting over some old F# code from CTP 1.9.6.8
The code uses List.first
:
List.first (fun x -> if x.Date = d then Some(x) else None)
List.first
has been deprecated. What is the current method used to achieve the same functionality.
I have reviewed the release notes and could not find any specific reference to the change.
Any help would be greatly appreciated.
Try List.pick
List.pick (fun x -> if x.Date = d then Some(x) else None)
@JaredPar is right.
Note that the F# library docs are here:
http://msdn.microsoft.com/en-us/library/ee353567(VS.100).aspx
and specifically the List module is here:
http://msdn.microsoft.com/en-us/library/ee353738(VS.100).aspx
and searching for 'first' on that page reveals the usual suspects.
What @JaredPar suggested with List.pick
is right, though it would raise a KeyNotFoundException
if the element does not exist.
You can use
List.tryPick
if you want an option
to be returned in both cases, found and not found.
It's use is the same:
List.tryPick (fun x -> if x.Date = d then Some(x) else None)
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