What's with tails?

51 views
Skip to first unread message

RZez...@gmail.com

unread,
Jun 1, 2009, 11:31:41 PM6/1/09
to Real World Haskell Book Club
First off, to the authors of RWH, thanks for the wonderful book! This
is the first book I've read where I felt like I was back in college
and had an actual professor teaching the subject matter to me! I
think because of the user contributed comments, this book reads much
better than just about any other technical book I have ever read.

To my question, why does tails include the full list as it's first
result? The book says it returns "all of them [the tails]." The
definition of the tail function is to return all but the head of the
list. I would image tails as a recursive call of tail, consing each
result to the next until you reach the end.

myTails :: [a] -> [[a]]

myTails [] = []
myTails (x:xs) = xs : myTails xs

*Main Data.List> myTails [1,2,3]
[[2,3],[3],[]]

Am I alone in my confusion?

BTW, does anyone post to the haskell-cafe or fa.haskll google groups,
or are they read-only groups of the mailing lists?

Thanks,
-Ryan
Reply all
Reply to author
Forward
0 new messages