CLOSE FULL VIEW
How to Think about Parallel Programming: Not!
Recorded at:
Community comments
excellent talk
by
peter lin
Posted
Inspiring. Inspiring.
by
Torsten Grust
Posted
Inspiring. Inspiring.
by
Torsten Grust
I can view this talk over and over again and find it more inspiring every time.
Thanks for posting.
—Torsten
Thanks for posting.
—Torsten
data WordState = Chunk String
| Segment String [String] String
deriving Show
maybeWord :: String -> [String]
maybeWord "" = []
maybeWord s = [s]
(⊕) :: WordState -> WordState -> WordState
Chunk s ⊕ Chunk s' = Chunk (s ++ s')
Chunk s ⊕ Segment l as r = Segment (s ++ l) as r
Segment l as r ⊕ Chunk s = Segment l as (r ++ s)
Segment l as r ⊕ Segment l' as' r' = Segment l (as ++ maybeWord (r ++ l') ++ as') r'
processChar :: Char -> WordState
processChar ' ' = Segment "" [] ""
processChar c = Chunk [c]
words s = case g of
Chunk s -> maybeWord s
Segment l as r -> maybeWord l ++ as ++ maybeWord r
where g = foldr1 (⊕) (map processChar s)
main = print (Main.words "Here is a sesquipedalian string of words")





Hello stranger!
You need to Register an InfoQ account or Login to post comments. But there's so much more behind being registered.Get the most out of the InfoQ experience.
Tell us what you think