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 6574071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:12:50+00:00 2026-05-25T15:12:50+00:00

After having a look at these two threads: Does F# have an equivalent to

  • 0

After having a look at these two threads: Does F# have an equivalent to Haskell's take? , Take N elements from sequence with N different indexes in F#
, I’ve been wondering about the best way to use sequence operators on lists or even if using them.

I am at the moment a newbie at F# and I’m writing a program which has to deal with lots of sequences that I get from HtmlAgilityPack. There are some interesting operators in the Seq module but as stated in those threads, it might be poor related to performance and if we are obliged to constantly converting between seq -> list it also clutters code with things that are not problem-solving… which is why I started learning F# in the first place.

A simple example is when I need to take ‘N’ elements of a list:

               listOfRows
               |> Seq.take 2
               // Now I don't have a list anymore, it returns a sequence
               |> List.ofSeq

So, could anyone shed some light about the best way to deal with these scenarios? I can work solutions using Seq.take and Seq.skip but this is known to be very inefficient. On the other hand it’s a shame to have the functionality built into the standard library and having to reimplement it for using the same concept on a different collection, or make the code dirtier with explicit conversions.

How could I see the performance impact each conversion between ‘list -> seq’ and ‘seq -> list’ has?

Thanks a lot.

  • 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-25T15:12:52+00:00Added an answer on May 25, 2026 at 3:12 pm

    Some of this might depend on exactly how you want to use all this end-to-end.

    In many cases it will be fine to convert to a list once up front, and then only use the List operators to map/traverse/etc. There may not be a List.take, but that’s because with lists, if you know there are going to be at least two elements and you want to grab those two, you can do it with a pattern match, e.g.

    let (item1::item2::rest) = someList
    

    So I suspect that may be what you want to do in this scenario (I expect with HTML parsing, you might have some kind of expected rough schema of elements you’re looking for, etc.).

    (If laziness/streaming is essential, then Seq becomes much more useful.)

    Briefly, the commonest operators (like map) are on all the collection types (Seq, List, Array, …) whereas the uncommoner ones (like take) are only available on Seq, often because there are better ways to do things when you have a concrete type (e.g. list pattern matching to take the first items).

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

Sidebar

Related Questions

After having looked at each of these two projects, it seems that both are
I look after builds of our products and have been asked to come up
After having read that QuickSilver was no longer supported by BlackTree and has since
After having solved the problem of getting the editor to launch when there's a
After having a search around I could not find exactly what I want, I
After having this question answered through a link to an external site , I
... after having just read http://www.cocoadev.com/index.pl?CocoaInsecurity ... I am curious to know about your
After having had a dev PC HD corrupt, I'm considering the idea of making
After having worked in MVC for a few months, I'm back in a previously
After having a period of logshipping failures going unnoticed (due to a stopped SQL

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.