I’m just beginning this nice hashkell beginners tutorial:
on this page on lists he explains that lists are compared in compared in lexicographical order, he gives this example:
ghci> [3,2,1] > [2,10,100]
True
From some googling it seems to me that lexicographical ordering means in alphabetical or sequential number ordering(?), but I still can’t make sense of this evaluating to True.
I’m missing something obvious here, can anybody help?
This evaluates to
Trueas 3 is greater than 2. Having found a result, the comparison stops here. He’s demonstrating that 2 and 10 are not compared. The result of the array comparison istrue. If the first array started with 2 as well, the comparison would result infalse.A nice example for when lexicographical ordering does not result in what the user would expect is file names in Windows. If you have files named
xyz1.txt,xyz2.txt,xyz10.txtandxyz20.txt, the lexicographical order would be:xyz1.txt,xyz10.txt,xyz2.txt,xyz20.txt