Question: Do these exercises while following the rules of FP; immutable data, referential transparency, no side effects, recursion rather than loops. 1 . write a function
Do these exercises while following the rules of FP; immutable data, referential transparency, no side effects, recursion rather than loops.
write a function getArea with an expression body, which takes a Double radius and returns the area of a circle with the given radius Math. PI times radius
Write a recursive function with an expression body that takes an Int n and returns a list of the areas of circles for each radius from n to in decreasing order. Get the areas by calling the area function you wrote in an earlier question.
Then rewrite the recursive function so that the areas appear in increasing order. You do not need to use tail recursion in this case we will talk about that later!
Create a list that uses your area function as an initializer and contains the areas of circles with each integer from to as radius.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
