Skip to content

Add a compose function #1

@natanfeitosa

Description

@natanfeitosa

Add a compose function

In computer science, function composition is an act or mechanism to combine simple functions to build more complicated ones. Like the usual composition of functions in mathematics, the result of each function is passed as the argument of the next, and the result of the last one is the result of the whole.

Source: Wikipedia

Usage examples

from pyfunctools.compose import compose

add_one = lambda x: x + 1
double = lambda x: x * 2

compose(add_one, double)(1) # -> 3

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions