
the first line says that 'fname' is a function which takes a list and returns a string. the list is of type '[([Char],a)]'. this means that it's a list of ([Char],a)s. these are pairs of [Char]s and as. a [Char] is a string (a string is a list of characters) and an a is a something -- anything you want. the second line tells you the value of fname when its argument list is empty ([]). the result in this case is the string "Result_Blank". the third line tells you what to do when the input is not empty. when you have a non-empty list, it's composed of a head and a tail, written (head:tail). since our list is of pairs, the head has the form (a,b). putting this together, we have that the list is of the form ((x,xs):ys). here, x is our a, xs is our b and ys is the tail. (x,xs) is our head. it then says that the result of this is just the value 'x'. this is simply the [Char] part (the first half) of the first pair in the list. HTH - Hal -- Hal Daume III | hdaume@isi.edu "Arrest this man, he talks in maths." | www.isi.edu/~hdaume
-----Original Message----- From: haskell-cafe-admin@haskell.org [mailto:haskell-cafe-admin@haskell.org] On Behalf Of Matthew Morvant Sent: Thursday, August 28, 2003 8:44 AM To: 'Haskell (haskell-cafe@haskell.org)' Subject: New to Haskell
Hello, I am very new to haskell. I was hoping someone could explain something to me
fname :: [([Char],a)] -> String fname [] = "Result_Blank" fname ((x,xs):ys) = x
What exactly [use little words :-)] does this do? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe