Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lookin for help for the following in Erlang can you answer all the Q as soon as you can thanks for your help.... lab04.erl screenshot/s

Lookin for help for the following in Erlang can you answer all the Q as soon as you can

thanks for your help....

image text in transcribed

image text in transcribed

lab04.erl screenshot/s of running lab04.erl in the shell showing various function calls (png, jpg, or gif) (capture any 4 function calls total, each one should illustrate a call to a different function though; 2 screenshots should be for one partner and 2 for the other) In the text editor of your choosing create a file lab04.erl and write function definitions that could be run from the shell - make sure you use the exact same names (anything in italics) as indicated in function descriptions. Pay attention to directions that specify what syntactical mechanisms to use within the functions (the purpose of this lab is to make sure you are familiar with most of the basic Erlang syntax discussed this week). 1. Function coneArea that takes two arguments that represent the radius of the base of a right circular cone and the height of that cone (in this order) and returns the surface area of that cone using the following formula: A = ar(r+h+r) you do NOT have to guard against invalid input; use pi and square root defined in the math library 2. Function is Different that takes two arguments and returns false if these two values are the same considering both the value and the type, i.e. if 5.0 and 5 are passed the function should return true because these two parameters have different data types; if 5 and 5 are passed, the function should return false because these two parameters have the same value and data type 3. Function smallerOne that takes two arguments and returns the smaller one - use the if statement inside the function body; if elements have the same value, returns either one 4. Function displayProperty that takes two arguments and evaluates whether they are odd or even or mixed. The function should print the following to the console: the incoming arguments (use the format specifier that will be appropriate for either floats or ints) the message: o "Both are even" if each one is an even number O "Both are odd" if each one of them is an odd number "One is odd, one is even" if one of the arguments is odd and the other one is even To write a boolean expression inside an if, use parenthesis around expressions, e.g. (x > 0) and (Y > 0). You may also solve this using nested ifs but then remember not to end a nested if with a period since the period indicates the end of a function. In this function we are not interested in a return value, although Erlang always returns, so write it as if Erlang did not always return (i.e. do not worry what this function will return, focus on what it is to 5. Function planets that takes an argument and returns its equivalent gas planet from our Solar System as an atom using a case expression, where: print. for value 1 returns jupiter for value 2 returns saturn for value 3 returns uranus for value 4 returns neptune for an invalid value, returns no_match 6. Function planets2 that works in the exact same fashion as planets, except uses function level pattern matching (several function clauses / headers) instead of a case expression inside a function. 7. Function myged that implements the recursive math formula provided below - do NOT write any if statements or case expressions inside the function body but rather use function level pattern matching m if m=n for m, n > 0, gcd (m, n) = gedm-n, n) if m>n ged(m, n-m) if m 0) and (Y > 0). You may also solve this using nested ifs but then remember not to end a nested if with a period since the period indicates the end of a function. In this function we are not interested in a return value, although Erlang always returns, so write it as if Erlang did not always return (i.e. do not worry what this function will return, focus on what it is to 5. Function planets that takes an argument and returns its equivalent gas planet from our Solar System as an atom using a case expression, where: print. for value 1 returns jupiter for value 2 returns saturn for value 3 returns uranus for value 4 returns neptune for an invalid value, returns no_match 6. Function planets2 that works in the exact same fashion as planets, except uses function level pattern matching (several function clauses / headers) instead of a case expression inside a function. 7. Function myged that implements the recursive math formula provided below - do NOT write any if statements or case expressions inside the function body but rather use function level pattern matching m if m=n for m, n > 0, gcd (m, n) = gedm-n, n) if m>n ged(m, n-m) if m<><>

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

Students also viewed these Databases questions

Question

What is a niche market?

Answered: 1 week ago