Skip to content

Instantly share code, notes, and snippets.

@klgraham
Created March 26, 2016 04:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klgraham/64336af3269e40de6235 to your computer and use it in GitHub Desktop.
Save klgraham/64336af3269e40de6235 to your computer and use it in GitHub Desktop.
func flatMap<B>(f: A -> Distribution<B>) -> Distribution<B> {
var d = Distribution<B>(get: {() -> Optional<B> in return nil})
d.get = {
(Void) -> B in return f(self.get()!).get()!
}
return d
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment