Question: Write your programs using Racket functional language. Run each of the programs as many times as necessary to show that different situations are handled properly.

Write your programs using Racket functional language.

Run each of the programs as many times as necessary to show that different situations are handled properly.

  1. n the beginning of each part of this problem, introduce a named value sqr3, which is 1.732. You will have to write a function my_calc that takes two numerical parameters. If the first parameter is 1, calculate the area of an equilateral triangle, whose side equals the second parameter of the function. If the first parameter is 2, calculate the area of the hexagon, whose side equals the second parameter of the function. For other values of the first parameter and for a non-positive second parameter return a false Boolean value.
  • (a)  Implement a function my_calc using a multiple-way selection structure when checking the value of the first parameter.
  • (b)  Implement a function my_calc using a two-way selection structure when checking the value of the first parameter.

  2.  Write a Racket function rem_two that takes a simple list as a parameter and returns a list identical to the parameter except with the second and third elements removed. If the given list does not  have at least 3 elements, the function should return an empty list. Remember that you are NOT allowed to use standard functions for finding the length of the list.

  3. Write a function my_delete that takes two parameters: an atom and a list (which may be a nested list). This function will produce a list, identical to its parameter list, except with all occurrences of an atom parameter removed, no matter how deep they were. The produced list should not have anything in place of the deleted atoms.


 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here are the Racket programs for the tasks you mentioned Implementing the mycalc function using a mu... View full answer

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!