13 lines
272 B
Text
13 lines
272 B
Text
structure Rational where
|
|
num : Int
|
|
den : Nat
|
|
inv : den ≠ 0
|
|
|
|
@[default_instance 200]
|
|
instance : OfNat Rational n where
|
|
ofNat := { num := n, den := 1, inv := by decide }
|
|
|
|
instance : ToString Rational where
|
|
toString r := s!"{r.num}/{r.den}"
|
|
|
|
#check 2 -- Rational
|