Easy way to make anonymous functions by partial application of operators.
Project description
An easy way to make lambdas by partial application of python operators.
Inspired by Perl 6 one, see http://perlcabal.org/syn/S02.html#The_Whatever_Object
Usage
from whatever import _, that
# get a list of guys names
names = map(_.name, guys)
names = map(that.name, guys)
odd = map(_ * 2 + 1, range(10))
squares = map(_ ** 2, range(100))
small_squares = filter(_ < 100, squares)
best = max(tries, key=_.score)
sort(guys, key=-that.height)
factorial = lambda n: reduce(_ * _, range(2, n+1))
NOTE: chained comparisons cannot be implemented since there is no boolean overloading in python.
TODO
make benches
use WhateverCode anonymous subclasses to optimize calls
optimized version which returns lambdas and partial ops instead of WhateverCode
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
whatever-0.2.2.tar.gz
(3.8 kB
view hashes)