Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
14
Task/Arithmetic-Rational/Groovy/arithmetic-rational-2.groovy
Normal file
14
Task/Arithmetic-Rational/Groovy/arithmetic-rational-2.groovy
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import org.codehaus.groovy.runtime.DefaultGroovyMethods
|
||||
|
||||
class RationalCategory {
|
||||
static Rational plus (Number a, Rational b) { ([a] as Rational) + b }
|
||||
static Rational minus (Number a, Rational b) { ([a] as Rational) - b }
|
||||
static Rational multiply (Number a, Rational b) { ([a] as Rational) * b }
|
||||
static Rational div (Number a, Rational b) { ([a] as Rational) / b }
|
||||
|
||||
static <T> T asType (Number a, Class<T> type) {
|
||||
type == Rational \
|
||||
? [a] as Rational
|
||||
: DefaultGroovyMethods.asType(a, type)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue