Created
November 12, 2023 23:21
-
-
Save artempyanykh/75ad27186adae657fd468be3fdb8ce26 to your computer and use it in GitHub Desktop.
F# custom operators
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
type Vec = | |
{ x: float | |
y: float | |
z: float } | |
static member (+)(v1, v2) = { x = v1.x + v2.x; y = v1.y + v2.y; z = v1.z + v2.z } | |
static member (*)(factor, v2) = { x = factor + v2.x; y = factor + v2.y; z = factor + v2.z } | |
let test (v1: Vec) (v2: Vec) = | |
let factorSum = 1.0 + 2.5 | |
let vSum = v1 + v2 | |
factorSum * vSum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment