A simple composition library
Project description
Compoz
Compoz is a lightweight composition package.
Overview
Compoz provides with two main functions:
- composite (for standard composition)
- pipe (for reversed composition)
'composite'
'composite' will run from last to the first function provided.
from compoz import composite
def multiply_by_3(n: int) -> int:
return n * 3
def subtract_5(n: int) -> int:
return n - 5
composite_func_1 = composite(subtract_5, multiply_by_3)
print(composite_func_1(10))
# Output will be 25
composite_func_2 = composite(multiply_by_3, subtract_5)
print(composite_func_2(10))
# Output will be 15
'pipe'
'pipe' will run from first to the last function provided.
from compoz import pipe
def multiply_by_3(n: int) -> int:
return n * 3
def subtract_5(n: int) -> int:
return n - 5
pipe_func_1 = pipe(subtract_5, multiply_by_3)
print(pipe_func_1(10))
# Output will be 15
pipe_func_2 = pipe(multiply_by_3, subtract_5)
print(pipe_func_2(10))
# Output will be 25
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
compoz-0.1.0b3.tar.gz
(2.3 kB
view hashes)