Advertisement
Guest User

Untitled

a guest
Jun 13th, 2021
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #not idiomatic but shows that the value is encapsulated in a container that provides extra context used by bind()
  2. Class Option
  3. Def __init__(self, x):
  4. Self.x=x
  5. Def is_none(self):
  6. Return self.x is None
  7.  
  8. Def bind(val, f):
  9. If val.is_none():
  10. # ignore the remainder of the program and return early
  11. Return None
  12. Else:
  13. Return f(val.x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement