[Haskell-beginners] Empty list

Joel Neely joel.neely at gmail.com
Thu Mar 26 11:54:29 UTC 2015


Given the distinction between lists and sets, you might also consider

Prelude Data.Set Data.List> [] `isInfixOf` [1,2,3]
True
Prelude Data.Set Data.List> (fromList []) `isSubsetOf` (fromList [1,2,3])
True

Of course `isInfixOf` is in general more restrictive than `isSubsetOf`, in
the sense that the infix relationship depends on ordering, which the subset
relationship does not.

Hope that helps,

-jn-



On Wed, Mar 25, 2015 at 8:55 AM, Shishir Srivastava <
shishir.srivastava at gmail.com> wrote:

> Hi,
>
> Can someone please explain why this results in error -
>
> [] `elem` [1,2,3]
>
> Shouldn't the empty set by definition be the element of all sets including
> a non-empty set ?
>
> I am assuming 'Lists' are different from 'Sets' in Haskell, if yes, is
> there a separate module for dealing/working with sets ?
>
> Thanks,
> Shishir Srivastava
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>


-- 
Beauty of style and harmony and grace and good rhythm depend on simplicity.
- Plato
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20150326/2f53f259/attachment.html>


More information about the Beginners mailing list