
I may have missed it in this thread, but if not, why didn't anyone suggest: trans [] = [] trans [x] = [x] trans ('a':_:xs) = 'a' : 'A' : trans xs trans (x:xs) = x : trans xs On Thu, 2010-04-29 at 05:46 -0700, Hein Hundal wrote:
Jean-Nicolas,
Here is a variation on Corentin's solution:
-- This function replaces every character that -- follows an 'a' with 'A'
repA :: String -> String
repA s = zipWith f (' ':s) s where f 'a' y = 'A' f x y = y
Cheers, Hein
From: Jean-Nicolas Jolivet
I'm trying to iterate through each character of a string (that part I can do!) however, I need to apply a transformation to each character...based on the previous character in the string! This is the part I have no clue how to do! [snip] while i < my_string length: if my_string[i-1] == some_char: do something with my_string[i] else do something else with my_string[i]
_______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners