4 ms·
Last reply. Probably. Here's `maybe` in TypeScript: const maybe = <T,>(f: (_: T) => T, d:T) => (x: T|null) => f(x || d); console.log(maybe((x) => 2 *
by itishappy 2y ago
Last reply. Probably. Here's `maybe` in TypeScript:
const maybe = <T,>(f: (_: T) => T, d:T) => (x: T|null) => f(x || d);
console.log(maybe((x) => 2 * x, 3)(null)); // returns: 6