Complex Number Type
parent
9d6e9e87fe
commit
7dc8a2f21e
|
@ -0,0 +1,21 @@
|
||||||
|
module Aufgabe_Complex exposing (..)
|
||||||
|
|
||||||
|
type alias Complex = { real : Float, imaginary : Float }
|
||||||
|
|
||||||
|
fromTuple : ( Float, Float ) -> Complex
|
||||||
|
fromTuple ( r, i ) = Complex r i
|
||||||
|
|
||||||
|
fromFloat : Float -> Complex
|
||||||
|
fromFloat r = Complex r 0
|
||||||
|
|
||||||
|
real : Complex -> Float
|
||||||
|
real c = c.real
|
||||||
|
|
||||||
|
imaginary : Complex -> Float
|
||||||
|
imaginary c = c.imaginary
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
c1 = fromTuple ( 1 , 2 )
|
||||||
|
c2 = fromFloat 3
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
module Aufgabe_Complex_Type exposing (..)
|
||||||
|
|
||||||
|
type Complex = Complex Float Float
|
||||||
|
|
||||||
|
fromTuple : (Float, Float) -> Complex
|
||||||
|
fromTuple (r, i) = Complex r i
|
||||||
|
|
||||||
|
fromFloat : Float -> Complex
|
||||||
|
fromFloat r = Complex r 0
|
||||||
|
|
||||||
|
real : Complex -> Float
|
||||||
|
real c = case c of Complex r i -> r
|
||||||
|
|
||||||
|
imaginary : Complex -> Float
|
||||||
|
imaginary c = case c of Complex r i -> i
|
Loading…
Reference in New Issue