> On May 1, 2017, at 8:29 PM, Xiaodi Wu via swift-evolution 
> <[email protected]> wrote:
> 
> Heck, we don't even have left padding for strings!

For what it's worth, a good Swift implementation of left-padding would probably 
*use* `repeatElement`:

        extension String {
                mutating func leftPad(to intendedCount: Int, with char: 
Character = " ") {
                        let extraCount = max(intendedCount - count, 0)
                        let extras = repeatElement(char, count: extraCount)
                        insert(contentsOf: extras, at: startIndex)
                }
        }

And, for that matter, `repeatElement` could be used to implement "repeat this 
collection":

        repeatElement(c, count: n).joined()

So I agree with you, Xiaodi, that there's no rush to do this. If we change our 
minds later, we can always turn `Repeated<T>` into a generic typealias for 
`RepeatedCollection<CollectionOfOne<T>>`.

-- 
Brent Royal-Gordon
Architechies

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to