Last active
January 7, 2019 14:39
-
-
Save andrevidela/8ec80d1a0afe697f021902feb2964aa6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Quadratic<A> { | |
let x²: A | |
let x: A | |
let c: A | |
} | |
extension Quadratic: Equatable where A: Equatable {} | |
extension Linear: FancyMult where A: Additive, A: Multiplicative { | |
typealias FancyVal = Quadratic<A> | |
static func ** (lhs: Linear<A>, rhs: Linear<A>) -> Quadratic<A> { | |
return Quadratic(x²: lhs.x * rhs.x, | |
x: lhs.x * rhs.c + lhs.c * rhs.x, | |
c: lhs.c * rhs.c) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment