[Haskell] How to substract a list?

Trevion trevion at gmail.com
Sun Mar 27 20:57:39 EST 2005


On Mon, 28 Mar 2005 01:53:39 +0200, Pierre Barbier de Reuille
<pierre.barbier at cirad.fr> wrote:
> ([1..10]++[1..10]) \\ [3..6]
> [1,2,7,8,9,10,1,2,7,8,9,10]
> 
> So _all_ the elements with values in [3..6] where removed !!
> If that's what you want ! Perfect ... if not : what do you want exactly
> ? List substraction is not uniq.

This is what I would have expected as well; however, the definition of
(\\) in the report uses delete, which only removes the first occurence
of each element in the second list from the first.  GHC 6.2.2 uses
that behavior as well, so:

Prelude Data.List> ([1..10] ++ [1..10]) \\ [3..6]
[1,2,7,8,9,10,1,2,3,4,5,6,7,8,9,10]

  .trev

-- 
As far as I can tell 
It doesn't matter who you are 
If you can believe there's something worth fighting for


More information about the Haskell mailing list