3 ms·
let persons = [ p | n <- names , p <- peopleNamed n , isValid p ] is even better, if your programming language has comp
by pklausler 10y ago
let persons = [ p | n <- names
, p <- peopleNamed n
, isValid p ]
is even better, if your programming language has comprehensions.
- aninhumer 10y agoEh, maybe for more complicated examples, but I think that comprehension is a lot more complicated than: filter isValid (map peopleNamed names)
- pklausler 10y agoExcept that doesn't support multiple people with the same name.
- aninhumer 10y agoWell I was basing mine on the original. If peopleNamed in fact returns a list, then I'm not really sure what it's doing to create that? (I assumed your example was Haskell, in which case I don't think it can do anything particularly useful) In any case, all you'd need to add is something like concat.