very simple how would you represent a list with no entries
Asked
Active
Viewed 135 times
2 Answers
4
An empty list is simply []
For example, defining a variable that holds an empty list can be done by:
emptyList :: [a]
emptyList = []

Yacoby
- 54,544
- 15
- 116
- 120
-
@delnan Thanks for pointing that out. I wasn't aware that there was a difference in terminology, however thinking of a function (mathematically) as `emptyList : [a] -> [a]` I suppose it wouldn't make sense to call something with no arguments a function. – Yacoby Mar 15 '11 at 19:58
-
That's not a variable either. (its value can not be varied) – Rotsor Mar 16 '11 at 01:56
-
1@Rotsor immutable variable are still variables ! See http://stackoverflow.com/questions/993124/does-haskell-have-variables – David V. Mar 16 '11 at 07:37