Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7677419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:25:05+00:00 2026-05-31T17:25:05+00:00

F# List provides the cons ( :: ) operator to add an item at

  • 0

F# List provides the cons (::) operator to add an item at the front of a list. Is there a function to do the same for the Seq? The only way I came across is using Seq.append as follows. Is there a more efficient/elegant way of doing this?

> let myLst = [1..5]
> 0::myLst;;
val it : int list = [0; 1; 2; 3; 4; 5]


> let mySeq = {1..5}
> Seq.append (seq [0]) mySeq;;
val it : seq<int> = seq [0; 1; 2; 3; ...]

Possible duplicate, but not really answering my question.

[1] uses Seq.append as above

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:25:07+00:00Added an answer on May 31, 2026 at 5:25 pm

    It may help to recall that F# sequence is a calculation, indeed. No matter how you are going to achieve it, in the end of the day you should have a new calculation that, if being enumerated, first yields the appended element, and then yields the old sequence. In most direct form this can be achieved using a sequence expression:

    > let mySeq = {1..5}
    > seq { yield 0; yield! mySeq };;
    val it : seq<int> = seq [0; 1; 2; 3; ...]
    

    Seq.append library function is just an optimized implementation of semantically the same action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a lower-level way to provide the list of loaders when rendering a
I want to have a select-only ComboBox that provides a list of items for
Is there a python package that provides list of all (or fairly complete) currencies
I'm trying to add a field to the List provided by the Spotify API.
What OCaml libraries are out there that provide lazy list handling? I am looking
Public web-site provides list of employees to Internet visitors. Contact information is hidden but
The website Domain Daily provides a list of new domain names. I have a
I have a Sencha app which performs geolocation, and provides a list of nearby
I have CameraList class that provides Cameras list like SONY,VIVOTEK,VIVOTEK 7XXX,PIXORD,TOSHIBA,JVC E-CON... And I
I have some legacy code that provides a list of the available COM ports

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.