beefyhalo
beefyhalo

Reputation: 1841

Functional combinator for filter then map

I have a collection of tuples of type (Boolean, A) which I'd like to transform to a collection of A.

Is there a well known combinator which does the following?

.filter(_._1).map(_._2)

Upvotes: 0

Views: 182

Answers (1)

Alexey Romanov
Alexey Romanov

Reputation: 170899

.collect { case (b, x) if b => x } (filter isn't an operation available on functors in general, so it depends on what exactly you mean by "I have a functor over the tuple (Boolean, A)")

Upvotes: 4

Related Questions