[Home] >  Function >  Create a function that accepts a single argument

Create a function that accepts a single argument

JavaScript version

const unary = (fn) => (arg) => fn(arg);

Examples

['1', '2', '3', '4', '5'].map(unary(parseInt)); // [1, 2, 3, 4, 5]