|
|
|
|
|
by greener_grass
830 days 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
|
|
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.htm... . We're in OO land here, not FP land.