Question: answer the following questions using Haskell: 1) Write your own recursive version of the map function, just like we did with filter. the example was:
answer the following questions using Haskell:
1) Write your own recursive version of the map function, just like we did with filter.
the example was:
module example where
pos x = x > = 0
filt p [ ] = [ ]
filt p (x h : x t) =
if p x h then x h : filt p x t
else filt p x t
2) Write a function that takes an integer and a List as arguments. If the integer argument is n, return the nth element of the list. If n is less than or equal to 1, return the first value. If n is greater than the length of the list, return the last value.
3) Create a custom type for representing regular polygons with two fields number of sides and side length. Create functions for checking equality (same side length and count), computing area, and checking for same area. When checking equality, you should define your function as an instance of Eq. Also, create a custom show function (instance of Show)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
