Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brianhicks/aaron
Syntactic sugar for function composition
https://github.com/brianhicks/aaron
Last synced: 24 days ago
JSON representation
Syntactic sugar for function composition
- Host: GitHub
- URL: https://github.com/brianhicks/aaron
- Owner: BrianHicks
- Created: 2012-09-07T04:04:29.000Z (over 12 years ago)
- Default Branch: develop
- Last Pushed: 2012-09-07T14:05:16.000Z (over 12 years ago)
- Last Synced: 2024-12-09T19:53:27.599Z (about 1 month ago)
- Homepage: http://aaron.readthedocs.org/en/latest/
- Size: 148 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Aaron
[![Build Status](https://secure.travis-ci.org/BrianHicks/aaron.png)](http://travis-ci.org/BrianHicks/aaron)
Aaron adds some syntactic sugar to Python function composition.
## How?
Say you have the following functions:
```python
def add_one(n):
return n + 1def double(n):
return n * 2def ints_less_than(n):
return range(1,n)def product(*ns):
result = 1
for n in ns:
result *= nreturn result
```You could do something like this:
```python
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:
```python
two_n_plus_one = double > add_oneproduct_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](http://en.wikipedia.org/wiki/Aaron_Copland). Get it?