Of course this probably makes most of you cringe, since this is not the way F# was meant to be used. This code has some "unkosher" concepts for F#, such as do-while loops and mutable data.

Nothing wrong with these things.

But what I would be interested in seeing is a "proper" F# translation with immutable data, and some sort of do-while equivalent.

I don't understand the code. There are things that are in each that are not in the other. Maybe you are trying to create a board with obstacles at nObstacles positions, randomly chosen? You could make a recursive "function" f n x where x is either a board or a list of positions, n is the number of obstacles to be added, and f 0 x = x. That would not involve mutable data but I think it's inferior from the point of view of both conceptual clarity and performance.

I can imagine wanting a board to be immutable, if you know it is immutable and you want to guarantee that no other part of the program changes it. But that's separate from the code that creates the board.

By on 3/23/2011 11:25 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper