Illustration

. A simple implementation of stacks (of ints) is shown here as a functional data structure in Language:Haskell:.

These stacks are immutable. The push operation does not modify the given stack; it returns a new stack which shares the argument stack possibly with other parts of the program. The pop operation does not modify the given stack; it returns a part of the argument stack. We refer to Document:Handbook of data structures and applications for a profound discussion of functional data structures including the stack example. The functions for operations top and pop, as given above, are partial because they are undefined for the empty stack.

There are also alternative illustrative Stack implementations available:

  • Fragment not found
    : Stacks are represented as lists while the Stack type is simply defined as a type synonym to this end. This implementation does not enforce information hiding.
  • Fragment not found
    : As before, stacks are represented as lists, but the Stack type is defined as a newtype which hides the representation as its constructor is not exported.
  • Fragment not found
    : As before, stacks are represented as lists and again this representation is hidden, but an additional data component for the size of the stack is maintained so that the size of a stack can be returned without traversing the stack.


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.