Skip to content

Instantly share code, notes, and snippets.

@dduan
dduan / Complex.swift
Last active August 29, 2015 14:12 — forked from mattt/Complex.swift
struct Complex<T: FloatLiteralConvertible> {
var real: T
var imaginary: T
}
func +(lhs: Complex<Double>, rhs: Complex<Double>) -> Complex<Double> {
return Complex<Double>(real: lhs.real + rhs.real, imaginary: lhs.imaginary + rhs.imaginary)
}
func -(lhs: Complex<Double>, rhs: Complex<Double>) -> Complex<Double> {