Playing devil's advocate here for a minute: The wanted functionality could 
also be reached using

Enum.sort(enumerable, &(DateTime.compare(&1, &2) in [:lt, :eq]))

for `DateTime.earliest`

and similarly:

Enum.sort(enumerable, &(DateTime.compare(&1, &2) in [:eq, :gt]))

for `DateTime.latest`.

Arguably this does require some mental gymnastics. However, is that enough 
reason to introduce eight new functions? (two for each of Time, Date, 
NaiveDateTime and DateTime)?

Maybe these mental gymnastics are not 'too bad'?
Or maybe we do want to make it somewhat easier for the users, but there 
exists a simpler, more fundamental alternative we could implement, which 
could then be re-usable in multiple contexts?

For instance, if we only had `DateTime.earliest(dt1, dt2)` then we could 
write:

Enum.sort(enumerable, &(DateTime.earliest(&1, &2) == &1))
for the first case, and 
Enum.sort(enumerable, &(DateTime.earliest(&1, &2) == &2))
for the second.

~Qqwy/Marten

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/00367262-834b-4fed-be94-dd2cc16e9157%40googlegroups.com.

Reply via email to