Debian Codegraph @

ipl/packs/idol/fraction.iol

raw
1 class fraction(n,d)
2 method n()
3 return self.n
4 end
5 method d()
6 return self.d
7 end
8 method times(f)
9 return fraction(self.n * f$n(), self.d * f$d())
10 end
11 method asString()
12 return self.n||"/"||self.d
13 end
14 method asReal()
15 return real(self.n) / self.d
16 end
17 initially
18 if self.d=0 then stop("fraction: denominator=0")
19 end