Headline

A programming idiom for computing a result along traversal of a data structure

Details

The idiom is approached differently depending on programming language and programming paradigm. For instance, in functional programming, the fold function may be used to model accumulation. The state monad may be also used for data structures other than lists. In logic programming, the predicates for traversal may use extra parameter positions for the accumulator's value before and after visiting a given term.

Illustration

Consider the following Language:Prolog code for computing maximum of a list of numbers:

max([H|T],M) :- max(T,H,M).

max([],M,M).
max([H|T],M1,M2) :- H > M1 -> max(T,H,M2); max(T,M1,M2).

For instance:

?- max([1,7,3],M).
M = 7.

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.

    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.