Skip to content

Instantly share code, notes, and snippets.

@talesin
Last active September 13, 2015 06:32
Show Gist options
  • Select an option

  • Save talesin/0a06d4f97cdc037fd58b to your computer and use it in GitHub Desktop.

Select an option

Save talesin/0a06d4f97cdc037fd58b to your computer and use it in GitHub Desktop.
F# Async filter
let filterAsync predicate (items:Async<_> list) = async {
let rec loop acc items' = async {
match items' with
| [] -> return acc
| x :: xs ->
let! item = x
return! loop (if predicate item then item :: acc else acc) xs
}
return! loop [] items
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment