Could you filter, then map? I'd try that instead of pattern matching.