Headline

Generic programming in Language:Python with SYB

Motivation

This implementation shows generic programming in Language:Python using SYB style. The data model relies on (recursive) data composition alone. Generic Programming simplifies the traversal over nested data. Functions for total and cut are implemented as generic functions, they contain type specific cases for Employees. This simplifies functional style traversing in Python a lot. This library is a port of the haskell version of SYB, but it addresses the same optimisations as those in haskell. For tree modification look at the implementation of cut and the implementation of total illustrates querys on a tree. The library depends on reflection in python to define gmapQ and gmapT.

Illustration

The data model is adapted from Contribution:py3k.

@t(Employee)
def salary(e):
    return e.salary

total = everything(operator.add, 0 |mkQ| salary)

This implementation of total takes the salary of every employee and folds them by adding.

Relationships

Usage

The python file "101companies.py" requires python2.5-2.7. The output appears on the console.

$ python 101company.py 
399747.0
199873.5

Metadata


There are no revisions for this page.

User contributions

    This user never has never made submissions.

    User edits

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.

    10 most similar pages:

    Syntax for editing wiki

    For you are available next options:

    will make text bold.

    will make text italic.

    will make text underlined.

    will make text striked.

    will allow you to paste code headline into the page.

    will allow you to link into the page.

    will allow you to paste code with syntax highlight into the page. You will need to define used programming language.

    will allow you to paste image into the page.

    is list with bullets.

    is list with numbers.

    will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.

    will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.

    will allow your to insert code snippets from @worker.