List attributes come in handy if the elements are somewhat complex and need to be filtered out by matching with the pattern, or the display part seems too complicated for the lambda abstraction, which should be short (or, it seems to me), or if one deals with nested lists. In the latter case, understanding the list is often more readable than alternatives (for me, anyway).
For example, something like:
[ (fb, (g . fst) a) | (Just a, Right bs) <- somelist, a `notElem` bs, (_, b) <- bs ]
But for your example, section (>4)
is a very good way to write (\a -> a > 4)
, and since you only use it for filtering, most people would prefer ANthonys solution.
source share