map
map¶
- map(f, r)[source]¶
Enables a computation on the value of a result
Example
>>> from math import sqrt >>> @wrap(ValueError) ... def parse(s: str) -> float: ... return float(s) >>> @wrap(ValueError) ... def square(f: float) -> float: ... return f*f >>> map(square, parse("2")) 4.0 >>> map(square, parse("-1")) 1.0 >>> flat_map(square, parse("invalid")) Err1(msg="ValueError thrown: could not convert string to float: 'invalid'", contexts=[])
- Parameters
- Return type
- Returns
Result parameterized by type ._ReturnType
See also
flatMap()