Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Syntactic sugar for function composition

branch: develop

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 aaron
Octocat-spinner-32 docs
Octocat-spinner-32 tests
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 README.md
Octocat-spinner-32 setup.py
README.md

Aaron

Build Status

Aaron adds some syntactic sugar to Python function composition.

How?

Say you have the following functions:

def add_one(n):
    return n + 1

def double(n):
    return n * 2

def ints_less_than(n):
    return range(1,n)

def product(*ns):
    result = 1
    for n in ns:
        result *= n

    return result

You could do something like this:

def two_n_plus_one(n):
  return add_one(double(n))

def product_of_lesser_numbers(n):
  return product(*ints_less_than(n))

Or, you could use Aaron, decorate your functions with composable, and do this:

two_n_plus_one = double > add_one

product_of_lesser_numbers = ints_less_than >> product

You've probably figured out by now that > is composition, and >> is will splat the results into the next function.

Aaron? What?

Yeah, the composer. Get it?

Something went wrong with that request. Please try again.