mardi 24 février 2015

How does string comparison work in Haskell? [duplicate]


This question already has an answer here:




I can't understand how Haskell compares between two Strings (of different length).


For example,



"abc" <= "ab"


returns False, whereas



"abc" <= "ac"


returns True.


Doesn't Haskell compare two Strings character by character? In the first example, I would have thought that



  • "a"<="a"

  • "b"<="b"

  • "c"<=""


and in the second example, I would have thought that



  • "a"<="a"

  • "b"<="c"

  • "c"<=""


What am I getting wrong?


Aucun commentaire:

Enregistrer un commentaire