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.
1. 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 ^2)
2. 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 1(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!)
3. Create a list that uses your area function as an initializer and contains the areas of circles with each integer from 1 to 25 as radius.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!