如何在 swift 3/4 中使用 range.map?

How to use range.map in swift 3/4?

我有下面的代码,它适用于 swift 2.3。我正在努力了解如何将其转换为 swift 3/4 - 这就是问题所在 Value of type 'Range<Int>' has no member 'map'

let grainSize = CGFloat(0.01)
        let min = CGFloat(-3)
        let max = CGFloat(3)
        let range = Range<Int>(uncheckedBounds: (lower: Int(min/grainSize), upper: Int(max/grainSize)))
        let lol = NSRange(range)

        var points = range.map { step -> CGPoint in
            let i = grainSize * CGFloat(step)
            let x = x_base + (i * controller.width / 4.0)
            let y = y_base + (m * equation(i))
            if x_init == CGFloat.max { x_init = x }
            return CGPointMake(x, y)
        }
        points.append(CGPointMake(x_init, y_base))
        points.forEach { renderer.lineTo([=12=]) }

我想知道是否有人可以为此指出正确的方向 - 甚至是关于此的文档,因为我在 apple 文档中也找不到任何相关信息 =[

Range不采用Sequence,直接创建范围为CountableClosedRange

let range = Int(min/grainSize)...Int(max/grainSize)