1

very simple how would you represent a list with no entries

Ahsan
  • 699
  • 2
  • 12
  • 18

2 Answers2

4

An empty list is simply []

For example, defining a variable that holds an empty list can be done by:

emptyList :: [a]
emptyList = []
Yacoby
  • 52,948
  • 13
  • 109
  • 118
  • @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
1

Also, "" is an empty String, and Strings are just lists of Chars.

Dan Burton
  • 52,501
  • 25
  • 112
  • 192