Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Here are the Racket programs for the tasks you mentioned Implementing the mycalc function using a mu... blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Principles Of Information Security

Authors: Michael E. Whitman, Herbert J. Mattord

7th Edition

035750643X, 978-0357506431

More Books

Students also viewed these Programming questions