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