15 lines
324 B
Swift
15 lines
324 B
Swift
//
|
|
// CollectionExtension.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 12/8/24.
|
|
//
|
|
|
|
extension Collection {
|
|
func mapIndexed<T>(_ transform: (Index, Element) -> T) -> [T] {
|
|
return self.enumerated().map { index, element in
|
|
transform(self.index(startIndex, offsetBy: index), element)
|
|
}
|
|
}
|
|
}
|