Assignment 6.2

Moderator: Type Systems of Programming Languages

AlexanderF
BASIC-Programmierer
BASIC-Programmierer
Beiträge: 140
Registriert: 2. Mai 2010 17:55

Assignment 6.2

Beitrag von AlexanderF »

hello,

first question:

in Assignment 6.2 we have to encode:

literals: complex = \re:Num. \im:Num. ?

has complex really to be a literal,
or is it more like a constructor,
that get two Numbers and yields an complex number?

so that the
complex has type: Num -> Num -> Complex
(where Complex is the type for complex numbers?)

second question:

In the past, I think Num was usually a Natural Number,
but I think it is not not possible to encode each complex number with 2 or any finite number of natural numbers or integers,
because complex numbers has a bigger cardinality than natural numbers or integers.

So can we assume Num stands for integer here,
and it suffices to encode only complex numbers where both real and imag part are integers,
also called: gaussian integers

regards,
Alexander

erdweg
Moderator
Moderator
Beiträge: 60
Registriert: 28. Mär 2013 10:08

Re: Assignment 6.2

Beitrag von erdweg »

yes to both of your questions:

complex has type: Num -> Num -> Complex

you can assume Num stands for integer here and it suffices to encode only complex numbers where both real and imag part are integers

Antworten

Zurück zu „Type Systems of Programming Languages“