In F# what is the most functional开发者_StackOverflow and idiomatic way of creating or "newing up" 100 new objects into a List.
I guess for an example we could use DateTime as an example object.
List.init 100 (fun x -> x * 2)
Alternatively, as a list expression:
[for i in 1..100 -> new System.DateTime()]
But I think this is less idiomatic.
I would consider using
[|for i in 1..100 -> new System.DateTime() |]
since you are working with mutable data.
精彩评论