> On Feb 17, 2017, at 10:38 AM, Abe Schneider via swift-evolution
> <[email protected]> wrote:
>
> If I read Nicolas's post correctly, I think he's more arguing for the
> ability to create syntax that allows Swift to behave in a similar way
> to Numpy/Matlab. While Swift already does allow you to define your own
> operators, the main complaint is that he can't define the specific
> operators he would like.
In Xcode 8.2.1, with the 8.2.1 toolchain, this works (well, it compiles…
obviously it doesn’t check for mis-matched array lengths):
infix operator .+
func .+ <T: Integer> (lhs: [T], rhs: [T]) -> [T] {
return zip(lhs, rhs).map { $0.0 + $0.1 }
}
print([1,2,3].+[4,5,6]) //outputs [5, 7, 9]
- Dave Sweeris_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution