← Back to challenges

Currying Functions

PythonHardfunctional_programmingarraysinterviewnumbersclosures

Instructions

Mubashir was reading about currying functions. He needs your help to multiply a list of numbers using currying functions.

Create a function which takes a list lst of integers as an argument. This function must return another function, which takes a single integer as an argument and returns a new list.

The returned list should consist of each of the elements from the first list multiplied by the integer.

Examples

multiply([1, 2, 3])(2) ➞ [2, 4, 6]

multiply([4, 6, 5])(10) ➞ [40, 60, 50]

multiply([1, 2, 3])(0) ➞ [0, 0, 0]

Notes

Your function must be called multiply.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.