Created
July 4, 2012 19:31
-
-
Save ssboisen/3049158 to your computer and use it in GitHub Desktop.
ReplaceElementAt alternatives
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ReplaceElementAt index element sequence = | |
let beforeIndex = sequence |> Seq.take index | |
let atIndex = element |> Seq.singleton | |
let afterIndex = sequence |> Seq.skip (index + 1) | |
Seq.append beforeIndex <| Seq.append atIndex afterIndex | |
let ReplaceElementAt index element sequence = | |
let beforeIndex = sequence |> Seq.take index | |
let afterIndex = sequence |> Seq.skip (index + 1) | |
seq { yield! beforeIndex; yield element; yield! afterIndex } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment