Headline

a Function for reversing a list

Illustration

Language:Haskell's reverse function for lists works like this:

Prelude> reverse [1,2,3]
[3,2,1]
Prelude> reverse "ABBA"
"ABBA"

In the first example, reverse is applied to a list of numbers.

In the second example, reverse is applied to a string, i.e., a list of characters.

Language:Haskell's reverse function for lists is defined like this:

reverse :: [a] -> [a]
reverse =  foldl f []
 where f = flip (:)

That is, reverse performs a left-associative fold that composes the current element and the recursive result of folding. We illustrate this by inlining the definition of foldl for a specific argument list:

reverse [1,2,3] = (([] `f` 1) `f` 2) `f` 3


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.