Is there any functional difference between Array.replicate and Array.create in F#?

Viewed 74

I was refactoring some code and noted that some coders used Array.replicate and other Array.create when initializing an array with repeatedly the same value. The signatures of both functions are identical:

> Array.create;;
val it : (int -> 'a -> 'a [])

> Array.replicate;;
val it : (int -> 'a -> 'a [])

I also noted that both raise an ArgumentException on a negative count value, and both allow a count of zero. My gut tells me they are synonymous, but then I found this quote on F# For Fun And Profit:

Array.create is basically the same as replicate (although with a subtly different implementation!) but replicate was only implemented for Array in F# v4.

Is anybody aware of what differences exist, or are they, for all intents and purposes, aliases of one another (perhaps replicate was merely added for parity with seq)?

1 Answers
Related