Filtering and mapping at the same time

Not too many people know about the function List.filterMap, which does both mapping and filtering in a single pass over the list:

List.filterMap : (a ->{𝕖} Optional b) -> [a] ->{𝕖} [b]

Here's a little example:

use Nat * <
go a = if a < 5 then Some (a * 100) else None
Nat.range 0 10 |> List.filterMap go
[0, 100, 200, 300, 400]

You can also use Stream.filter and Stream.map in combination, and these will fuse together via the magic of laziness:

[0, 100, 200, 300, 400]