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

  • Home
  • SEARCH
  • 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 8971521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:58:42+00:00 2026-06-15T17:58:42+00:00

I’m doing a project called 2D Shape editor in f#. I have done this

  • 0

I’m doing a project called “2D Shape editor” in f#. I have done this project in c# before so I’ve got all the logics for how to connect two shapes. So I know that i will need a list to hold all theese shapes that I will be adding. But I simply can’t get my addToList method to work.

My ShapeList:

let mutable ShapeList:List<RectangleZ> =  [RectangleZ(100,100)] 

My add methods:

let addToList (listan:List<RectangleZ>) (element:RectangleZ) = let ShapeList =     ShapeList@[element] in ShapeList
//Method to add into the ShapeList

let addToList (listan:List<RectangleZ>) (element:RectangleZ) = element::ShapeList
//Other try on adding into shapeList

the button that should be adding rectangles to the ShapeList:

btn.Click.Add(fun _ -> new RectangleZ(500, 100) |> addToList ShapeList |>ignore |> saver)
//Button click method that should be adding the RectangleZ(500, 100) to my ShapeList

And ofcourse my rectangle:

type RectangleZ(x:int, y:int)= 
  let mutable thisx = x
  let mutable thisy = y
  let mutable thiswidth = 50
  let mutable thisheight = 20
  let brush = new SolidBrush(Color.Black)
  member obj.x with get () = thisx and set x = thisx <- x
  member obj.y with get () = thisy and set y = thisy <- y
  member obj.width with get () = thiswidth and set width = thiswidth <- width
  member obj.height with get () = thisheight and set height = thisheight <- height
  member obj.thisColor = Color.FromArgb(167, 198, 253)
  member obj.draw(paper:Graphics) = paper.FillRectangle(brush, thisx, thisy, 50, 20)
  member obj.ShapeType = "Rectangle"

The element dosn’t get added into the list for some reason in neither of my addToList functions. My Question is why?

  • 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-06-15T17:58:43+00:00Added an answer on June 15, 2026 at 5:58 pm

    List in F# are immutable. This means that when you add item to list like this:

    let newlist = elem :: tail;;
    

    old list (tail) doesn’t changes, instead of that new list created. So, you need to return new list from your addToList function and than update mutable variable:

    let addToList (listan:List<RectangleZ>) (element:RectangleZ) = element::listan
    ShapeList <- addToList ShapeList newElement
    

    In your code let ShapeList is local and doesn’t affect global ShapeList variable.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.