Python when function - to apply a function when predicate(x) is True
Sat Jan 11 2020 20:54:48 GMT+0000 (Coordinated Universal Time)
Saved by @dry_toasts #python #function
Tests a value, x, against a predicate function, conditionally applying a function. Check if the value of predicate(x) is True and if so return when_true(x), otherwise return x.
https://www.30secondsofcode.org/python/s/when/
Comments