
Hi, This may have been asked before, sorry if so. I've wondered where the convention of pattern matching a list to (x:xs) came from? I've read a couple of old papers recently which let me believe it may have started back in the '70s with Miranda and its ilk. Does anyone know why (x:xs)? Is xs meant to be a synonym for 'excess'? Yours curiously, Toby.

Pattern matching goes back to Burstall and Darlington's work in the 1970's. As for "x:xs", the "xs" is meant to be the plural of "x", and is pronounced "exs" (I guess...). Similarly, "n:ns" is one n followed by many more "ens". Make sense? (By the way, ":" is often pronounced "followed by".) -Paul Hudak Toby Hutton wrote:
Hi,
This may have been asked before, sorry if so. I've wondered where the convention of pattern matching a list to (x:xs) came from? I've read a couple of old papers recently which let me believe it may have started back in the '70s with Miranda and its ilk.
Does anyone know why (x:xs)? Is xs meant to be a synonym for 'excess'?
Yours curiously, Toby.

Paul Hudak
As for "x:xs", the "xs" is meant to be the plural of "x", and is pronounced "exs" (I guess...). Similarly, "n:ns" is one n followed by many more "ens". Make sense?
I think this convention is often used in the Prolog community as well, as in "X|Xs". -- Doug Quale

Quoth Toby Hutton, nevermore:
Does anyone know why (x:xs)? Is xs meant to be a synonym for 'excess'?
I've seen it said somewhere (possibly Hudak's _Haskell School of Expression_) that "xs" should be read as the plural of "x". Although personally I always gravitate towards the "excess" notion, because it's such a nice word ;-) -- Dougal Stanton
participants (4)
-
Doug Quale
-
Dougal Stanton
-
Paul Hudak
-
Toby Hutton