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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:51:19+00:00 2026-05-24T11:51:19+00:00

I’m a C# developer new to F#,I understand that in .net the strings are

  • 0

I’m a C# developer new to F#,I understand that in .net the strings are immutable. In other words every time you modify a string you get a new string instance.

For a non functional mind like mine the first question would be efficiency and I understand that C# mutable objects are not persistent. since string manipulation is normally trivial in most of applications.

My question is, Is this the case for F# lists too?, Do F# clones every list on change? Like for example, when filtering a list do I create a new list with fewer Items?

Update: I’m not comparing .net string and lists. I named string as an example of an immutable object and want to know if F# provides any special treatment for it’s List.

This is what I mean by “persistent“.

  • 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-24T11:51:19+00:00Added an answer on May 24, 2026 at 11:51 am

    I think Dustin Campbell’s introduction does an amazing job of explaining list immutability.

    In the functional world, lists are immutable. This means that node sharing is possible because the original lists will never change. Because the first list ends with the empty list, its nodes must be copied in order to point its last node to the second list. After the append operation, our lists look like so:

    enter image description here

    At this point, the more skeptical among you might be saying, “Well,
    that’s a pretty interesting theory, but can you prove it?”

    No problem.

    Using the knowledge that F# lists are recursive, we can retrieve the
    last half of combined (the inner list starting at 4) by taking the
    tail, of its tail, of its tail. List.tl is the function that F#
    provides for extracting a list’s tail.

    > let lastHalf = List.tl (List.tl (List.tl combined));;
    
    val lastHalf : int list
    
    > lastHalf;;
    
    val it : int list = [4; 5; 6]
    

    Finally, because F# is first-class citizen of the .NET Framework, we
    have full access to all of the base class libraries. So, we can use
    the Object.ReferenceEquals method to test whether or not lastHalf
    and second are indeed the same instance.

    > System.Object.ReferenceEquals(lastHalf, second);;
    
    val it : bool = true
    

    And there you have it. Believe it or not, appending two immutable
    lists can actually be faster and more memory efficient than appending
    mutable lists because fewer nodes have to be copied.

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

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.