[Haskell-beginners] Filter to a list of function

Brent Yorgey byorgey at seas.upenn.edu
Sun Jul 7 19:53:41 CEST 2013


No need to apologize for grammar. =) There are lots of people in the
Haskell community with many different levels of English fluency, we
all just try to communicate as best we can.

As for your question, I am not quite sure I understand what you want.
Do you mean that you want to "zip" the lists together, applying each
function to one element?  As in

  specificFilter [(>3), even, (<19)] [6, 7, 8] = [6,8]

because 6>3 and 8>19 (but 7 is not even)?

If that is what you mean, then you could do something like

  specificFilter ps xs = map snd . filter fst $ zipWith (\p x -> (p x, x)) ps xs

If you mean something else, then maybe you could give some examples of
what you want?

-Brent

On Sun, Jul 07, 2013 at 02:32:21PM -0300, Igor Pinheiro Leão wrote:
> Hum.. really sorry about the grammar mistakes.
> 
> 
> 2013/7/7 Igor Pinheiro Leão <ivpcl at cin.ufpe.br>
> 
> > Hi Guys,
> > sorry in upsetting you again.
> > Is there a way in which I can filter one list of function, one function at
> > time, to a list of elements, declaring this and only this function.
> >
> > It would be exactly like this:
> >
> > specifcFilter :: [(a->Bool)] -> [a] -> [a]
> >
> > where for each element of type 'a' on the second list it would exist a
> > function on  the first list that would be applied to it filtering.
> >
> > Kind regards,
> > Igor
> >
> >
> > --
> > Igor Vinícius
> > Graduando em Ciência da Computação
> >
> 
> 
> 
> -- 
> Igor Vinícius
> Graduando em Ciência da Computação

> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners




More information about the Beginners mailing list