Skip to main content Accessibility help
×
Hostname: page-component-76fb5796d-9pm4c Total loading time: 0 Render date: 2024-04-28T09:33:39.766Z Has data issue: false hasContentIssue false

11 - Sequences

Published online by Cambridge University Press:  05 May 2013

Michael R. Hansen
Affiliation:
Technical University of Denmark, Lyngby
Hans Rischel
Affiliation:
Technical University of Denmark, Lyngby
Get access

Summary

A sequence is a possibly infinite, ordered collection of elements seq [eo; e1;…]. The elements of a sequence are computed on demand only, as it would make no sense to actually compute an infinite sequence. Thus, at any stage in a computation, just a finite portion of the sequence has been computed.

The notion of a sequence provides a useful abstraction in a variety of applications where you are dealing with elements that should be processed one after the other. Sequences are supported by the collection library of F# and many of the library functions on lists presented in Chapter 5 have similar sequence variants. Furthermore, sequences can be defined in F# using sequence expressions, defining a process for generating the elements.

The type seq<′a> is a synonym for the .NET type IEnumerable<′a> and any .NET framework type that implements this interface can be used as a sequence. One consequence of this is, for the F# language, that lists and arrays (that are specializations of sequences) can be used as sequence arguments for the functions in the Seq library. Another consequence is that results from the Language-Integrated Query or LINQ component of the .NET framework can be viewed as F# sequences. LINQ gives query support for different kinds of sources like SQL databases and XML repositories.

Type
Chapter
Information
Publisher: Cambridge University Press
Print publication year: 2013

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

Save book to Kindle

To save this book to your Kindle, first ensure coreplatform@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about saving to your Kindle.

Note you can select to save to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be saved to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

  • Sequences
  • Michael R. Hansen, Technical University of Denmark, Lyngby, Hans Rischel, Technical University of Denmark, Lyngby
  • Book: Functional Programming Using F#
  • Online publication: 05 May 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9781139093996.012
Available formats
×

Save book to Dropbox

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Dropbox.

  • Sequences
  • Michael R. Hansen, Technical University of Denmark, Lyngby, Hans Rischel, Technical University of Denmark, Lyngby
  • Book: Functional Programming Using F#
  • Online publication: 05 May 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9781139093996.012
Available formats
×

Save book to Google Drive

To save content items to your account, please confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your account. Find out more about saving content to Google Drive.

  • Sequences
  • Michael R. Hansen, Technical University of Denmark, Lyngby, Hans Rischel, Technical University of Denmark, Lyngby
  • Book: Functional Programming Using F#
  • Online publication: 05 May 2013
  • Chapter DOI: https://doi.org/10.1017/CBO9781139093996.012
Available formats
×