Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

-- Part 2: Function implementations -- 1. Transposes a 2-row x 2-column tuple. -- -- e.g., transposeTup ((1,2),(3,4)) = ((1,3),(2,4)) transposeTup :: ((a,b),(c,d)) -- input

-- Part 2: Function implementations

-- 1. Transposes a 2-row x 2-column tuple.

--

-- e.g., transposeTup ((1,2),(3,4)) = ((1,3),(2,4))

transposeTup :: ((a,b),(c,d)) -- input matrix

-> ((a,c),(b,d)) -- transposed matrix

transposeTup = undefined

-- 2. Sorts the elements of a 3-tuple.

--

-- e.g., sort3Tup (2,1,3) = (1,2,3)

-- sort3Tup (3,2,1) = (1,2,3)

sort3Tup :: Ord a

=> (a,a,a) -- input 3-tuple

-> (a,a,a) -- sorted 3-tuple

sort3Tup = undefined

-- 3. Computes the compound interest earned.

-- e.g., compoundInterest 100 0.2 1 = 20

-- compoundInterest 100 0.2 2 = 44

compoundInterest :: Floating a

=> a -- principal

-> a -- rate

-> Int -- num of compounding periods

-> a -- amount of compound interest earned

compoundInterest = undefined

-- 4. Computes the length of the Collatz sequence starting at the input.

--

-- e.g., collatzLen 1 = 0

-- collatzLen 6 = 8

-- collatzLen 27 = 111

collatzLen :: Integer -- start value of the sequence

-> Integer -- length of sequence

collatzLen = undefined

-- 5. Computes the square root of the input using Newton's method.

--

-- e.g., newtonsSqrt 2 ~= 1.4142...

-- newtonsSqrt 1000 ~= 31.6227...

newtonsSqrt :: (Floating a, Ord a)

=> a -- x

-> a -- square root of x

newtonsSqrt = undefined

-- 6. Draws a planet in a circular orbit given an orbital radius and period.

drawOrbit :: Float -- radius

-> Float -- period

-> Float -- time

-> Picture

drawOrbit _ _ _ = blank

-- 7. Draws a planet in an elliptical orbit based on Kepler's equation.

drawOrbit' :: Float -- semi-major axis

-> Float -- eccentricity

-> Float -- period

-> Float -- time

-> Picture

drawOrbit' _ _ _ _ = blank

meanMotion :: Floating a

=> a -- period

-> a -- mean motion

meanMotion p = undefined

meanAnomaly :: Floating a

=> a -- mean motion

-> a -- time

-> a -- mean anomaly

meanAnomaly n t = undefined

eccentricAnomaly :: (Floating a, Ord a)

=> a -- eccentricity

-> a -- mean anomaly

-> a -- eccentric anomaly

eccentricAnomaly ecc ma = undefined

trueAnomaly :: (Floating a, Ord a)

=> a -- eccentricity

-> a -- eccentric anomaly

-> a -- true anomaly

trueAnomaly ecc ea = undefined

heliocentricDist :: Floating a

=> a -- semi-major axis

-> a -- eccentricity

-> a -- eccentric anomaly

-> a -- heliocentric distance

heliocentricDist a ecc ea = undefined

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions