[prev in list] [next in list] [prev in thread] [next in thread] 

List:       hugs-users
Subject:    Re: [Hugs-users] converting to capital letters
From:       "Neil Mitchell" <ndmitchell () gmail ! com>
Date:       2006-10-19 21:16:26
Message-ID: 404396ef0610191416q846e88du8c5a7f6c2ea66e69 () mail ! gmail ! com
[Download RAW message or body]

Hi Alex,

I suggest you try haskell-cafe@haskell.org, its a much better place to
ask these sorts of Haskell style questions.

The answer is to use an "if" expression somewhere, I'll leave you to
figure out where :)

Thanks

Neil

On 10/19/06, Alex Teslin <alexteslin@yahoo.co.uk> wrote:
> Hi,
> I am a newbie in Haskell and have some problem of defining a function that
> would convert all small letters to capital and leave the rest intact.
> I have managed to do with two functions:
>
> capitalise :: String -> String
> capitalise xs = [capitalise2 ch| ch<-xs]
>
> capitalise2 :: Char -> Char
> capitalise2 ch
>     | isLower ch    = chr (ord ch - 32)
>     | otherwise    = ch
>
> But in the book exercise it asks to define as a single function. I tried
> like this:
>
> capitalise :: String -> String
> capitalise xs = [chr (ord ch - 32) | ch<-xs, isLower ch]
>
> But this returns only converted characters, the rest is ignored.
>
> Any help would be much appriciated.
>
>
>  Send instant messages to your online friends http://uk.messenger.yahoo.com
> _______________________________________________
> Hugs-Users mailing list
> Hugs-Users@haskell.org
> http://www.haskell.org/mailman/listinfo/hugs-users
>
>
>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic