Using decorator(@) notation
from Curry import curry
@curry
def split_by(character, word):
return word.split(character)
OR passing the function to be curried to curry function.
def split_by(character, word):
return word.split(character)
split_by = curry(split_by)
When we use curry on a function, allow us to "consume" such function, bit by bit, also called partial application of the function. We don't need to pass all the parameter at once.
split_by_spaces = split_by(' ')
split_by_spaces('Hello my name is Emerson')
#['Hello', 'my', 'name', 'is', 'Emerson']