Headline

Anonymous functions in Haskell

Characteristics

The contribution demonstrates functional programming in Haskell. Specifically, anonymous functions in the form lambda abstractions are put to work as arguments of higher-order functions for list processing.

Illustration

Anonymous functions are functions without name. They can be used as "in-place" arguments of higher-order functions, thereby eliminating the need of a definition in a local or a global scope, thereby making some definitions more concise. For comparison, consider the following functions for totaling salaries, as part of Contribution:haskellWhere:

-- Total all salaries in a company
total :: Company -> Float
total (n, es) = sum (map totalE es)

-- Extract the salary from an employee
totalE :: Employee -> Float
totalE ( ,  , s) = s

When anonymous functions are put to work, then the same functionality is implemented as follows:

-- Total all salaries in a company
total :: Company -> Float
total (n, es) = sum (map (\( , ,s) -> s) es)

Thus, the named helper function totalE is gone; map is applied instead to an anonymous function.

Relationships

Architecture

See Contribution:haskellEngineer.

Usage

See Contribution:haskellEngineer.


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.

    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.