
29 Apr
2010
29 Apr
'10
8:46 a.m.
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]