# [Haskell] How to substract a list?

Bright Sun bright_sun at yahoo.com
Sun Mar 27 19:42:07 EST 2005

```Tks Arjun,

This is what I want.

Thanks very much.

Bright

--- Arjun Guha <guhaarju at grinnell.edu> wrote:
> Try this:
>
>  > remove theList toRemove = filter (\x -> not (elem
> x toRemove)) theList
>
> -Arjun
>
> On Mar 27, 2005, at 18:28, Bright Sun wrote:
>
> > Hi,
> >
> >  Tks, this is not what I wanted.
> >
> > I want remove pairs list,
> >
> >  [(5,1),(4,1),(3,1),(2,1),(1,1)] remove
> [(2,1),(1,1)]
> >  [(5,1),(4,1),(3,1)]
> >
> > so pairs [(2,1),(1,1)] removed.
> >
> > Tks.
> >
> > --- Pierre Barbier de Reuille
> >  <pierre.barbier at cirad.fr> wrote:
> >  > One answer is the infix operator (\\) defined
> in the
> >  > List module (or in
> > > Data.List ...)
> >  >
> > > But it's in ont of the "set" operations. For
> example
> >  > try :
> >  >
> > > [1..10] \\ [3..6]
> >  > [1,2,7,8,9,10]
> >  >
> > > But also :
> >  >
> > > ([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.
> >  >
> > > Pierre
> >  >
> > > Bright Sun a écrit :
> >  > > In Haskell, ++ can spends second list
> argument
> >  > onto
> >  > > the end of first list argument.  How to
> substract
> >  > the
> >  > > second list from the first list?
> >  > >
> > > > For example,
> > > > [(5,1),(4,1),(3,1),(2,1),(1,1)]
> > > > substract
> >  > > [(2,1),(1,1)]
> > > > I want to get result list:
> >  > > [(5,1),(4,1),(3,1)]
> > > >
> > > > Tks.
> > > >
> > > >
> > > >
> > > > __________________________________
> >  > > Do you Yahoo!?
> > > > http://www.yahoo.com/r/hs
> > > >
> _______________________________________________
> > > > Haskell mailing list
> > > >
> > > >
> > >
> > > --
> > > Pierre Barbier de Reuille
> >  >
> > > INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII
> AMAP
> >  > Botanique et Bio-informatique de l'Architecture
> des
> >  > Plantes
> >  > TA40/PSII, Boulevard de la Lironde
> >  > 34398 MONTPELLIER CEDEX 5, France
> >  >
> > > tel   : (33) 4 67 61 65 77    fax   : (33) 4 67
> 61
> >  > 56 68
> >  >
> >
> >
> >
> >
> >  __________________________________
> >  Do you Yahoo!?
> > Yahoo! Small Business - Try our new resources
> site!
> > _______________________________________________