(1) Have a look at take (2) Have a look at break and span
-----Original Message----- From: Vardhan Varma [mailto:vardhan@cadence.com] Sent: Monday, April 07, 2003 5:31 AM To: haskell@haskell.org Subject: newbie Q: [a] -> [[a]]
Hello, Please help me with this: I'm absolute newbie in Haskell, I hope I'm posting to right forum.
(1) For "abcdefgh" -> ["ab","cd","ef"] I figured this out: foo (x:y:z) = ( (x:y) :(foo z)) Now how generalize this to club 'n' chars instead of two ? 3 -> "abcdefgh" -> ["abc","def","gh"] i.e. n -> [Char] -> [ [Char] ] -- all except last element have length == n
(2) My original problem is of splitting by markers. "a<b>cd<efg>hi" -> [ "a" , "b", "cd", "efg", "hi" ] I'm at total loss on how to do it. Any pointer will be appreciated.
--TIA --Vardhan _______________________________________________ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell