Headline

An expression form to discriminate between different results

Illustration

Case expressions are typically available in functional programming languages as a means to perform pattern matching over values of algebraic data types. For instance, consider the following function in Language:Haskell:

length :: [a] -> Int
length [] = 0
length (_:xs) = 1 + length xs

This definition expresses case discrimination in terms of multiple equations, but we could define a variation on length so that case discrimination is expressed by a single expression instead:

length' :: [a] -> Int
length' l =
  case l of
    [] -> 0
    (_:xs) -> 1 + length' xs

A case expression may feature multiple branches in the same way as a function definition may feature multiple equations. In essence, the syntax of having multiple equations is "syntactic sugar; we can always suffice with function definitions with just one equation and reside to case expressions for pattern matching. Also, case expression is more general in so far that it is an expression form which does not require the introduction of an explicit function name.

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.