PDA

View Full Version : easy question


mightymonkey
03-10-2004, 11:56 PM
Im sure this question is very easy but Im very new to Haskell and dont know how to do this.
I have writtel a function X that takes a character and an integer as input (it returns a character)
I want to write a function that takes a string and an integer, sends each character of the string through the X function with the integer and returns a new string of all the characters changed by the X function.

Regards,

Mixy.

GnuVince
03-11-2004, 02:54 AM
Transform your string in a list of characters and then use the map function

Free2Frag
03-11-2004, 05:16 AM
1-Never ever call functions X sooo annoying and confusing

2-Map is the better idea but for clearer understanding try recursion which is mighty useful in Haskell

urFunction charList number
|charList==[]=[]
|otherwise = smallFunction (head charList) number : urFunction(tail charList) number

Smerdyakov
03-11-2004, 01:17 PM
In Haskell, strings are lists of characters by definition.