7 ms·
NonEmptyList<'t> has a method Uncons that returns 't * List<'t> List<'t> has a function TryUncons that gives Option<'t * List<'t>> List<'t> does not have a me
by greener_grass 2y ago
NonEmptyList<'t> has a method Uncons that returns 't * List<'t>
List<'t> has a function TryUncons that gives Option<'t * List<'t>>
List<'t> does not have a method Uncons.
We can define TryUncons for NonEmptyList<'t> in terms of Uncons, specifically:
this.TryUncons() =
this.Uncons()
|> Some
- jerf 2y agoI didn't spell it out adequately, only implied it, but I am talking about a fully loaded List, not one that just barely works, e.g., it has filter, it has all the other things you'd expect from a List. I did discuss the "just barely works" case at the end. It would be an odd "object oriented language" list that lacked such things, e.g., https://docs.oracle.com/javase/8/docs/api/java/util/List.html#remove-int- https://docs.oracle.com/javase/8/docs/api/java/util/List.htm... . We're in OO land here, not FP land.