# May I ask what is the meaning of ch <= 'z' and 'a' <= ch. Classic List Threaded 3 messages Reply | Threaded
Open this post in threaded view
|

## May I ask what is the meaning of ch <= 'z' and 'a' <= ch.

 Hello everyone, I have a simple question here     Define a function `isLower :: Char -> Bool` which returns `True` if a given character is a lower case letter. You can use the fact that characters are ordered, and for all lower case letters ch we have ′a′ ≤ ch and ch ≤ ′z′. Alternatively, you can use the fact that `['a'..'z']` evaluates to a list containing all lower case letters.    And May I ask what is the meaning of ch <= 'z' and 'a' <= ch? I copied this as a condition and solved the problem.here is my work.    isLower :: Char -> Bool    isLower x = if x ch <= 'z' && 'a' <= ch then True else False.    Thanks in advance._______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

## Re: May I ask what is the meaning of ch <= 'z' and 'a' <= ch.

 On Tue, Apr 10, 2018 at 08:47:17PM +0800, 清羽 wrote: >     And May I ask what is the meaning of ch <= 'z' and 'a' <= ch? I copied this as a condition and solved the problem.here is my work. >     isLower :: Char -> Bool >     isLower x = if x ch <= 'z' && 'a' <= ch then True else False. >     Thanks in advance. Hello 清羽, Char is an instance of Ord, so you can use <, compare, etc. with it. <= and >= stand for "less or equal than" and "greater or equal than". As with many enumeration types, the order is a bit arbitrary     λ> minBound :: Char     '\NUL'     λ> maxBound :: Char     '\1114111'     λ> ['\$'..'Z']     "\$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ"             -- so * will be < than, say, A     λ> '*' < 'A'     True Does that answer your question? _______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

## Re: May I ask what is the meaning of ch <= 'z' and 'a' <= ch.

 In reply to this post by 清羽 'ch' here is a variable, standing for 'character.' It takes the place of 'x'. Your solution is almost correct, you just need to pick one name or the other for your variable.On Tue, Apr 10, 2018, 5:51 AM 清羽 <[hidden email]> wrote:Hello everyone, I have a simple question here     Define a function `isLower :: Char -> Bool` which returns `True` if a given character is a lower case letter. You can use the fact that characters are ordered, and for all lower case letters ch we have ′a′ ≤ ch and ch ≤ ′z′. Alternatively, you can use the fact that `['a'..'z']` evaluates to a list containing all lower case letters.    And May I ask what is the meaning of ch <= 'z' and 'a' <= ch? I copied this as a condition and solved the problem.here is my work.    isLower :: Char -> Bool    isLower x = if x ch <= 'z' && 'a' <= ch then True else False.    Thanks in advance._______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners _______________________________________________ Beginners mailing list [hidden email] http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners