This can help remember that the F # sequence is a calculation. Regardless of how you are going to achieve this, at the end of the day you should have a new calculation, which, being enumerated, first gives the added element, and then returns the old sequence. In its most direct form, this can be achieved by expressing the sequence :
> let mySeq = {1..5} > seq { yield 0; yield! mySeq };; val it : seq<int> = seq [0; 1; 2; 3; ...]
Seq.append A library function is simply an optimized implementation of the semantically same action.
Gene belitski
source share