Groups
Groups
Sign in
Groups
Groups
haskell.cn
Conversations
About
Send feedback
Help
写了一个Python风格的字符串split函数……
14 views
Skip to first unread message
Blade Wang
unread,
May 30, 2010, 3:58:36 PM
5/30/10
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to haskell.cn
RT,不知有没有更好的方式来作和Python中string.split相同的事?
这是我写的一个,请路过的各位大虾指点!
> module MySplit (split) where
> split :: String -> String -> [String]
> split s tkn | l == 0 = [s]
> | otherwise = _split s
> where
> l = length tkn
> _split x | tkn == take l x =
> "": (_split $ drop l x)
> | null x =
> "":[]
> | otherwise =
> (head x : head sp) : tail sp
> where
> sp = _split $ tail x
Reply all
Reply to author
Forward
0 new messages