Docs‎ > ‎OpenSource‎ > ‎

pyfnc


Overview

This project consists of functional programming tools for Python.  The source code can be found on github.  The Ohloh project page is located here.

Pattern Matching Function Dispatch

This functionality is inspired from Erlang.


With pyfnc, the example above would translate to the following:



Functional dictionary

Wouldn't it be nice to chain operations on dictionaries?

>>> from pyfnc import dic
>>> d=dic()
>>> d.update(other_dic).get(some_key, some_default)

Another example:

>>> from pyfnc import dic
>>> d=dic()
>>> value=d.update(other_dic).all( lambda key, value: (key.lower(), value.lower()) )["this_key"]

Functional list

Wouldn't it be nice to chain operations on lists?

>>> from pyfnc import liste
>>> l=liste()
>>> l.extend(other_list).map(some_function)

Another example:

>>> from pyfnc import liste
>>> l=liste(some_list)
>>> count_even=l.count(lambda x:x%2==0)


More examples

More examples can be found by perusing the unittest here.




Comments

Feeds