Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does the name "xs" for pattern matching come from? [duplicate]

Possible Duplicate:
What is the history of the variable names x and xs?

Where does the canonical name "xs" in pattern matching come from?

e.g. in

reverse' []     = []
reverse' [x]    = [x]
reverse' (x:xs) = reverse' xs ++ [x]  

Is it supposed to be the plural of "x" ?

like image 749
Frank Schmitt Avatar asked Dec 04 '12 10:12

Frank Schmitt


1 Answers

That's the way I've always read it, you have the singular and the plural, So x:xs or y:ys etc.

It doesn't actually have any meaning by itself, it's just a convention.

IIRC it's also mentioned in Learn You a Haskell.


Edited

My mistake - it's actually in Real World Haskell in the chapter on types and functions.

enter image description here

like image 158
Abizern Avatar answered Sep 29 '22 16:09

Abizern