#haskell - Fri 9 Mar 2007 between 07:40 and 07:49

NY Lost Funds



bakert> break (== ',') "hello,there"
lambdabot("hello",",there")
actiondancor schedules some learning to spell
dancorschedules some learning to spell
bakert?t splitAt
lambdabotMaybe you meant: tell temp time tiny-url todo todo-add todo-delete topic-cons topic-init topic-null topic-snoc topic-tail topic-tell type . ft v
bakert:t splitAt
lambdabotforall a. Int -> [a] -> ([a], [a])
nominolodancor: see the Haskell Prime wiki
?where haskell prime
lambdabothttp://haskell.org
quicksilvercuriously 'split at commas' isn't anywhere in the standard library
that is, there is no generalisation of 'unwords' to non-space-chars
nominolo?src unwords
lambdabotunwords [] = ""
unwords ws = foldr1 (\w s -> w ++ ' ':s) ws
Thunde1@pl \w s -> w ++ ' ':s
nominolo:t words
lambdabot(. (' ' :)) . (++)
String -> [String]
nominolo?src words
lambdabotwords s = case dropWhile isSpace s of
"" -> []
s' -> w : words s'' where (w, s'') = break isSpace s'
quicksilversorry, I mean 'words' not 'unwords'
I always get those two backwards, oddly
nominolowell, as you can see, it's break
Thunde1@type curry (:)
lambdabotforall a b. a -> b -> [(a, b)] -> [(a, b)]
quicksilverthe reason there isn't one is probably that there are a few possible variants you can imagine: constant strings, constant chars, char predicate, string predicate
and the question of whether you keep the delimeters in the output or not
earthythat's what we've got parser combinators for
nominoloa regexp-based implementation probably works best in any case
Thunde1@type uncurry (:)
lambdabotforall a. (a, [a]) -> [a]
quicksilverearthy: well, yes
earthy: but it's still a question that often comes up "Why isn't this minor generalisation of words in the library"
Thunde1@pl \x xs -> x : words xs
lambdabot(. words) . (:)
nominolo> break (==';') "foo;basd;fds;..."
lambdabot("foo",";basd;fds;...")

Page: 3 10 17 24 31 38 45 52 59 66 73 80 87 94 

IrcArchive

NY Lost Funds