Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement DivideByInt

Tags:

f#

I'm trying to write a custom DivideByInt as follows

type Pair = Pair of int * int with
    static member DivideByInt pair int = pair


[<EntryPoint>]
let main argv =
    LanguagePrimitives.DivideByInt (Pair(1,2)) 1 
    |> ignore 
    0

// compiler error: "FS0001: Method or object constructor 'DivideByInt' not found"

Why's the compiler not finding Pair.DivideByInt?

like image 216
Murray Avatar asked Jan 29 '23 12:01

Murray


1 Answers

Pair.DivideByInt has to take a tuple as input

the corrected version:

type Pair = Pair of int * int with
    static member DivideByInt (pair, int) = pair
like image 75
Murray Avatar answered Feb 04 '23 19:02

Murray