Welcome back to Haskell Function of the Day! Today we'll talk about cute little function in Prelude that can be useful for processing text: 'words'. It takes a string and breaks it into words delimited by white space. It returns a list of strings where each item in the string is a particular word. For example > words "This is a test" ["This","is","a","test"] One thing to keep in mind is that 'words' regards punctuation marks as part of the words to which they are attached... or even as separate words entirely. > words "This, my friend, is a test !" ["This,","my","friend,","is","a","test","!"] Notice the trailing commas on "This," and "friend," and notice that the final '!' is a word by itself (due to the space separating it from "test" in the original string). Sophisticated text processing applications would probably find this behavior a little simplistic so some preprocessing or post processing might be necessary. There is a corresponding 'unwords' function that does the reverse of 'words.' Thus > unwords ["This", "is", "a", "test"] "This is a test" The cool part is that you can combine these functions with other list handling techniques. > let sentence = "This is a test" > length (words sentence) 4 > (words sentence) !! 3 "test" > unwords (reverse (words sentence)) "test a is This" Be sure you understand why these results are produced. Notice the difference between the last example and > reverse sentence "tset a si sihT" And, of course, pattern matching works. > let (firstWord:remainingWords) = words sentence > firstWord "This" > unwords remainingWords "is a test" That's it for today's edition of Haskell Function of the Day. I hope you enjoyed it! Peter