How can I initialize a sequence in F# with existing items?

f#, sequence

Solution

To create an (immutable) F# list, you can write:

let list = [ obj1; obj2; obj3 ]

There is a number of other options. You can create arrays by using `[| .. |]` instead of `[ .. ]` and you can also write sequence expressions that allow you to generate data - similarly to C# iterator methods. For more information, refer to:

- Sequences at F# WikiBook

- Sequences (F#) at MSDN

Problem

In C#, you can initialize a list like so: ``` var list = new List<int> { obj1, obj2, obj3 }; ``` I was expecting to do something similar in F# but keep getting errors: ``` let list = { obj1, obj2, obj3 } ``` Is this possible in F#?

Original source