[Haskell-beginners] Empty list

Mike Meyer mwm at mired.org
Wed Mar 25 14:11:07 UTC 2015


On Wed, Mar 25, 2015 at 9:03 AM, Brandon Allbery <allbery.b at gmail.com>
wrote:

> On Wed, Mar 25, 2015 at 10:00 AM, Norbert Melzer <timmelzer at gmail.com>
> wrote:
>
>> You are correct, a list is not a set. A list is a list of things, that
>> can be there multiple times. A set is a set of things, where nothing can be
>> twice. So take a look at Data.Set
>>
>
> Note that this won't actually solve the original problem; Haskell is an
> implementation of a strongly typed lambda calculus, not of number theory,
> and Haskell collections cannot (easily) contain elements of different types
> --- so the empty set is not an element of a set, and the empty list is not
> an element of a list.
>

Did you forget a couple of "necessarily"'s?

Prelude Data.Set> [] `elem` [[]]
True
Prelude Data.Set> empty `member` (insert empty empty)
True
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150325/7ff0cf94/attachment.html>


More information about the Beginners mailing list