My first guess would be, that the range is made into a list of elements [1,2,3,…] and the > compare the length of the list with the other side. I will take a longer look into now.
The arguments can be of different data types. The following order is defined:
number < atom < reference < fun < port < pid < tuple < map < nil < list < bit string
Edit 2:
Ah okay,
and the third of our examples would be explained by that fact, that lists are compare element for element. So after 10 comparision you compare a not-empty list with an empty one, resulting in an empty list being “less” than the not empty one.
Same source, next line
nil in the previous expression represents the empty list (), which is regarded as a separate type from list/0. That is why nil < list.
Edit 3:
As @LostKobrakai notes, it’s map, not a list. Still wondering how these are compared. Value by value, maybe?
Worth mentioning that if you try to compare range literals on recent Elixir versions you’ll get a warning:
iex(1)> 1..20 > 1..10
warning: invalid comparison with struct literal 1..20. Comparison operators (>, <, >=, <=) perform structural and not semantic comparison. Comparing with a struct literal is unlikely to give a meaningful result. Modules typically define a compare/2 function that can be used for semantic comparison
iex:1
true