Skip to main content

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


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.3.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file whatever-0.3.tar.gz.

File metadata

  • Download URL: whatever-0.3.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for whatever-0.3.tar.gz
Algorithm Hash digest
SHA256 61bcd24933753f066bcbfc4103547e8c10a9c66d9f5138a258297e0bc75134c3
MD5 e341545a2a4d78bdc0ff16e56ee9176e
BLAKE2b-256 daf7fab2c5b045a0c5d3d45c4fcc2cc516c0d050d9eb13245a5f63b3d3bd0c6e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page