Skip to content

Complex number

Given a file named “main.scm” with:

(import (scheme base) (scheme inexact) (scheme complex))
(write-u8 (if (= (real-part <expression>) <value>) 65 66))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

expressionvalue
(make-rectangular -42 0)-42
(make-rectangular -1 0)-1
(make-rectangular 0 0)0
(make-rectangular 1 0)1
(make-rectangular 42 0)42
(make-polar -1 -1)(- (cos -1))
(make-polar -1 1)(- (cos 1))
(make-polar 1 -1)(cos -1)
(make-polar 1 1)(cos 1)

Given a file named “main.scm” with:

(import (scheme base) (scheme inexact) (scheme complex))
(write-u8 (if (= (magnitude <input>) <output>) 65 66))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

inputoutput
-22
-11
11
22

Given a file named “main.scm” with:

(import (scheme base) (scheme inexact) (scheme complex))
(write-u8 (if (= (angle <input>) <output>) 65 66))

When I successfully run stak main.scm

Then the stdout should contain exactly “A”.

inputoutput
-2(acos -1)
-1(acos -1)
10
20