Skip to content

Instantly share code, notes, and snippets.

@artempyanykh
Created November 12, 2023 23:21
Show Gist options
  • Save artempyanykh/75ad27186adae657fd468be3fdb8ce26 to your computer and use it in GitHub Desktop.
Save artempyanykh/75ad27186adae657fd468be3fdb8ce26 to your computer and use it in GitHub Desktop.
F# custom operators
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