Skip to content

Instantly share code, notes, and snippets.

@xnyhps
Created January 11, 2015 10:48
Show Gist options
  • Save xnyhps/0835e1b94b6021aa66fb to your computer and use it in GitHub Desktop.
Save xnyhps/0835e1b94b6021aa66fb to your computer and use it in GitHub Desktop.
func replicate<C : ExtensibleCollectionType>(s:Int, x:C) -> C {
var ret : C = C()
for element in x {
for i in 1...s {
ret.append(element)
}
}
return ret
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment