Tuesday 15 March 2011

Haskell replace space with Char -



Haskell replace space with Char -

i'm trying come function replace blank spaces in string "%50" or similar , know i'm messing types can't seem figure out have been trying next (yes have imported data.char)

newline :: string -> string newline xs = if x `elem` " " "%50"

i tried if else statement didn't know else figured lowercase letters with

newline xs = [if x `elem` ' ' '%50' else tolower x | x<-xs]

would else statement nil have searched , found no way of doing figured if lowercase wouldn't matter trying work.

try simple solution

newline :: string -> string newline "" = "" newline (' ':xs) = '%':'5':'0': newline xs newline (x:xs) = x: newline xs

or utilize library function

haskell

No comments:

Post a Comment