To help you better understand what functions are available in the Haskell libraries I thought I would periodically pick a function (or related functions) to highlight in a short message like this. I'll start with functions in the Prelude module since that module is always available (like package java.lang in Java programs). Thus the functions it contains tend to be essential. Today's Haskell Function of the Day is splitAt. First let's look at its type signature (the sessions below are all from ghci). > :type splitAt splitAt :: Int -> [a] -> ([a], [a]) Here the 'a' is a type variable that represents any type at all. Read 'a' as "alpha." This reading is appropriate because in the theory of programming languages greek letters are usually used for type variables. So splitAt is a function that takes an Int and a list, and returns a pair of lists. Note that the type of the list elements is completely generic; it can be any type at all (that's what is meant when a type variable is used like this). The function splitAt splits a list at a particular point, returning the two lists that result. Lets see it in action > splitAt 3 [10, 11, 12, 13, 14, 15] ([10,11,12],[13,14,15]) Recall that list indicies start at zero. Thus element number 3 in the list above is the 13. That also is the first element of the second list (or just past the last element of the first list). What happens if you do odd things? Haskell functions tend to take sensible actions. Observe: > splitAt 3 [1, 2, 3] ([1,2,3],[]) > splitAt 4 [1, 2, 3] ([1,2,3],[]) > splitAt 0 [1, 2, 3] ([],[1,2,3]) > splitAt (-1) [1, 2, 3] ([],[1,2,3]) Notice that in the first case the split point (3) is actually just off the end of the list. The list elements are numbered 0, 1, and 2. Notice also that the parenthesis are needed around (-1). Without them Haskell thinks you are trying to do the subtraction 'splitAt - 1' which makes no sense since splitAt is a function. Of course since strings are just lists of characters, splitAt works perfectly fine with strings also > splitAt 3 "HelloWorld" ("Hel","loWorld") That's it for today's edition of Haskell Function of the Day! I hope you enjoyed it. Peter