Archive for February, 2009

Feb 25 2009

Python to Haskell (String Functions)

Published by tim under coding, haskell

I will be updating this as I go… but see also the Wikipedia page on string functions in various languages.
Joining a string list

– Python: ",".join(lst)
– either…
import Data.List
intercalate "," lst
– or…
import Data.List
concat (intersperse "," lst)

Splitting on a string

– a.split(ss)
– You might need to get Data.List.Split from Cabal
import Data.List.Split
splitOn ss a
– using regexes
import Text.Regex
splitRegex (mkRegex [...]

No responses yet

Next »