Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
26
Task/Arithmetic-Complex/Oforth/arithmetic-complex-1.oforth
Normal file
26
Task/Arithmetic-Complex/Oforth/arithmetic-complex-1.oforth
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
Number 100 Class newPriority: Complex(re, im)
|
||||
|
||||
Complex method: re @re ;
|
||||
Complex method: im @im ;
|
||||
|
||||
Complex method: initialize := im := re ;
|
||||
Complex method: << '(' <<c @re << ',' <<c @im << ')' <<c ;
|
||||
|
||||
Integer method: asComplex self 0 Complex new ;
|
||||
Float method: asComplex self 0 Complex new ;
|
||||
|
||||
Complex new(0, 1) Constant new: I
|
||||
|
||||
Complex method: ==(c) c re @re == c im @im == and ;
|
||||
Complex method: norm @re sq @im sq + sqrt ;
|
||||
Complex method: conj Complex new(@re, @im neg) ;
|
||||
Complex method: +(c) Complex new(c re @re +, c im @im +) ;
|
||||
Complex method: -(c) Complex new(c re @re -, c im @im -) ;
|
||||
|
||||
Complex method: *(c) Complex new(c re @re * c im @im * -, c re @im * @re c im * + ) ;
|
||||
Complex method: inv
|
||||
| n |
|
||||
@re sq @im sq + asFloat ->n
|
||||
Complex new(@re n /, @im neg n / ) ;
|
||||
|
||||
Complex method: /(c) c self inv * ;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
2 3.2 I * + .cr
|
||||
Complex new(2, 3) 1.2 + .cr
|
||||
Complex new(2, 3) 1.2 * .cr
|
||||
2 Complex new(2, 3) / .cr
|
||||
Loading…
Add table
Add a link
Reference in a new issue