Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello please I need help with the following question coding I need you to use Erlang only, if possible answer all the questions please. I

Hello please I need help with the following question coding I need you to use Erlang only,

if possible answer all the questions please.

I have the question and need it to be answer please in Erlang only.

here is it

If you are not able to answer it all please do the first part 1 to number 3 if possible

I really appreciated.

here is the first part asking to create some function in Erlang coding. and i will include the 2nd part as a screenshot and the some code in text

for question 4 is as text

image text in transcribed

4. Function myPartition that behaves exactly like lists:partition does, i.e. you are writing your own implementation of this function, as if the library one was not available; you can/should use lists:filter though while implementing this function.Download the file bst.erl discussed during the lectures and add the following functions. Test them in the shell:

the file code is

-module(bst).

-export([insert/2]).

-type bst() :: empty | { integer(), bst(), bst()}.insert(N, Tree) ->

case Tree of

empty -> {N, empty, empty};

{Value, Left, Right} ->

if

N {Value, insert(N, Left), Right};

N > Value -> {Value, Left, insert(N, Right)}

end

end.

== In the text editor of your choosing create a file lab06.erl and write function definitions described below make sure you use the exact same names as indicated in the description. Test all functions in the shell. 1. Function eqWrapper that takes one argument; if the value of this argument is character (not atom) v, then eqWrapper returns a function that takes two values and compares them using = operator (the returned function returns true or false when called itself); if the value of the eqWrapper argument is character (not atom) t, it returns a function that takes two values and compares them using =:= operator (the returned function returns true or false when called itself). Write the functions to be returned as anonymous functions inside the body of eqWrapper. Double check how to denote characters in Erlang, as opposed to atoms. Do not worry about invalid input. 2. Function cuboid Volume that takes two arguments that represent the length and width of a cuboid (box-shaped object) and returns an inner function. This inner function is set up to take the height of that cuboid and to return the volume of that cuboid using the following formula: Volume = Length x Width x Height you do NOT have to guard against invalid input; 3. Function mapReduce that takes 4 parameters: two functions (the first will be used in lists:map, the second one in lists:foldl), an accumulator value for fold, and a list, and returns a value calculated by first applying a map to the list, then applying a fold to the list returned from the map; use map and fold defined in the list library but NOT mapfold; for example if the first function flips the sign and the second one calculates the product, then the list (3,6) should result in (-3,-6] after sending it to the map, and in 18 after sending it to fold when calling the function from the shell, use an anonymous function as the first argument in the call that flips the sign and use an anonymous function for the second argument in the call that calculates the product add function flip(N) -> -1 * N to your lab06.erl and then call function mapReduce from the shell again, this time passing flip as the first argument . == In the text editor of your choosing create a file lab06.erl and write function definitions described below make sure you use the exact same names as indicated in the description. Test all functions in the shell. 1. Function eqWrapper that takes one argument; if the value of this argument is character (not atom) v, then eqWrapper returns a function that takes two values and compares them using = operator (the returned function returns true or false when called itself); if the value of the eqWrapper argument is character (not atom) t, it returns a function that takes two values and compares them using =:= operator (the returned function returns true or false when called itself). Write the functions to be returned as anonymous functions inside the body of eqWrapper. Double check how to denote characters in Erlang, as opposed to atoms. Do not worry about invalid input. 2. Function cuboid Volume that takes two arguments that represent the length and width of a cuboid (box-shaped object) and returns an inner function. This inner function is set up to take the height of that cuboid and to return the volume of that cuboid using the following formula: Volume = Length x Width x Height you do NOT have to guard against invalid input; 3. Function mapReduce that takes 4 parameters: two functions (the first will be used in lists:map, the second one in lists:foldl), an accumulator value for fold, and a list, and returns a value calculated by first applying a map to the list, then applying a fold to the list returned from the map; use map and fold defined in the list library but NOT mapfold; for example if the first function flips the sign and the second one calculates the product, then the list (3,6) should result in (-3,-6] after sending it to the map, and in 18 after sending it to fold when calling the function from the shell, use an anonymous function as the first argument in the call that flips the sign and use an anonymous function for the second argument in the call that calculates the product add function flip(N) -> -1 * N to your lab06.erl and then call function mapReduce from the shell again, this time passing flip as the first argument

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

The Myth Of Measurement Inspection Audit Targets And The Public Sector

Authors: Nick Frost

1st Edition

1529732662, 978-1529732665

More Books

Students also viewed these Accounting questions