Complex Number Type

main
Yan Wittmann 2022-10-24 09:10:05 +02:00 committed by Skyball2000
parent 9d6e9e87fe
commit 7dc8a2f21e
7 changed files with 36 additions and 0 deletions

View File

@ -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

View File

@ -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