March 2014 update

This commit is contained in:
Ingy döt Net 2014-04-02 16:56:35 +00:00
parent 09687c4926
commit a25938f123
1846 changed files with 21876 additions and 5203 deletions

View file

@ -0,0 +1,14 @@
$SET SOURCEFORMAT "FREE"
$SET ILUSING "System"
$SET ILUSING "System.Numerics"
class-id Prog.
method-id. Main static.
procedure division.
declare num as type Complex = type Complex::ImaginaryOne()
declare results as type Complex occurs any
set content of results to ((num + num), (num * num), (- num), (1 / num), type Complex::Conjugate(num))
perform varying result as type Complex thru results
display result
end-perform
end method.
end class.

View file

@ -0,0 +1,13 @@
add[x,y] := x + y
multiply[x,y] := x * y
negate[x] := -x
invert[x] := 1/x // Could also use inv[x] or recip[x]
conjugate[x] := Re[x] - Im[x] i
a = 3 + 2.5i
b = 7.3 - 10i
println["$a + $b = " + add[a,b]]
println["$a * $b = " + multiply[a,b]]
println["-$a = " + negate[a]]
println["1/$a = " + invert[a]]
println["conjugate[$a] = " + conjugate[a]]

View file

@ -0,0 +1,16 @@
extern crate num;
use num::complex::Cmplx;
fn main() {
let a = Cmplx::new(-4.0, 5.0);
let b = Cmplx::new(1.0, 1.0);
println!("a = {}", a);
println!("b = {}", b);
println!("a + b = {}", a + b);
println!("a * b = {}", a * b);
println!("1 / a = {}", Cmplx::new(1.0, 0.0) / a);
println!("-a = {}", -a);
println!("conj a = {}", a.conj());
}