func withUnsafePointers<R>(_ list: [[Float]], _ body: @escaping ([UnsafePointer<Float>])->R) -> R { func process(_ list: [[Float]], _ ptrs: [UnsafePointer<Float>]) -> R{ if list.isEmpty { return body(ptrs) } else { return list.first!.withUnsafeBufferPointer { p in process(Array(list.dropFirst()), ptrs + [UnsafePointer(p.baseAddress!)]) } } } return process(list, []) }
(edited)