Question

Please help me with Haskell structure question. Thank you Define function least that receives three numbers...

Please help me with Haskell structure question. Thank you

Define function least that receives three numbers and returns the least value, in the following cases.

(a) Use min function.

(b) Use if-expressions.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
"least" function definition :

(a). Using min function
least :: Int -> Int -> Int -> Int
least a b c = min a (min b c)

(b). Using if-expression

least :: Int -> Int -> Int -> Int

least a b c = a, if a < b && a < c

= b, if b < a && b < c

= c, if c <a && c < b

Add a comment
Know the answer?
Add Answer to:
Please help me with Haskell structure question. Thank you Define function least that receives three numbers...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Haskell Define function-divisors that receives a number and returns a list of all divisors of that...

    Haskell Define function-divisors that receives a number and returns a list of all divisors of that number.For example, if the input is 20, then the output would be[1,2,4,5,10,20]. You may use list comprehension, list ranges, and function mod for this purpose.Hint:Given numbern, consider all numbers from 1 ton, and then keep only the ones that dividen.

  • (IN HASKELL) Declare the type and define a function (say fun) that takes two whole numbers...

    (IN HASKELL) Declare the type and define a function (say fun) that takes two whole numbers (say m and n) as input. The function then returns m ^ n. That is, m to the power of n. Please use recursion only, you should not use m ^ n, or pow or any other library function, only recursion.

  • Please use Haskell, thank you! For this question, you will implement (under specific constraints) a recursive...

    Please use Haskell, thank you! For this question, you will implement (under specific constraints) a recursive function in Haskell that takes a list of characters as an argument and returns a list that contains only every third element from the argument list in the same order. As a clarifying example, this function, when passed the argument list “ABCDEFGHIJKLMNO”, should return the list “ CFILO”. It should also be noted that your function must work (i.e., not terminate with an error)...

  • Hi everyone, I need help In Haskell Coding. Please code in Haskell, Regards 1) Write a...

    Hi everyone, I need help In Haskell Coding. Please code in Haskell, Regards 1) Write a function that takes a list of tuples of three integers each and returns a list consisting of just the tuples that are Pythagorean triples. instead of using a list comprehension, use lambda expression and a function that tests one tuple and returns a Bool. As long as the lambda expression is correct, it is OK to make this simpler by having the lambda calls...

  • Hi Every one, hope all is well. I need help in Using Haskell coding Please, please...

    Hi Every one, hope all is well. I need help in Using Haskell coding Please, please read the instructon very carefully to: (in Syntax Code please) NOTE: function headers (for example, for the area-of-a-rectangle function, do not need to write area :: Int-> Int-> Int at the top of your function). You may use the :{ ... :} syntax to write multi-line functions in prelude Haskell platform. Write a function that takes three numbers, a b, and c, and returns...

  • please help me with this question thank you very much in advance Using a structure and...

    please help me with this question thank you very much in advance Using a structure and an appropriate fixed integer datatype, declare a bit-field consisting of the following fields: bmonth: 4 bits bday: 5 bits bweekday: 3 bits cgrade: 4 bits Use tag_data as the tag name of this structure. TTT Arial 1412pt T Path: P Words:0

  • Write another function buddies(...) that receives a list (with at least 3 integer numbers), and returns...

    Write another function buddies(...) that receives a list (with at least 3 integer numbers), and returns the number of pairs of buddies in the list. We will define a “pair of buddies” to be the pair of elements that are contiguous in the list and that are equal, and also so that the contiguous elements to the pair are different (or the pair is in an extreme of the list). For example, [5,2,2,3] has 1 pair of buddies (the 2’s)...

  • Please help me with the following question...not sure if my selection is correct. Thank you. You...

    Please help me with the following question...not sure if my selection is correct. Thank you. You may change your response by submitting again. Which structure represents a polar molecule?

  • Define a function add_nums_x_pos_given_list_nums (..) which receives a list that is guaranteed to only have numbers...

    Define a function add_nums_x_pos_given_list_nums (..) which receives a list that is guaranteed to only have numbers (or the empty list) and returns the sum of each number multiplied by the position where the number is. (In the case of the empty list the function it will return 0) For example add_nums_x_pos_given_list_nums ([10,20,30]) will return the value 80 which is the result of adding: 0 * 10 (10 is in position 0 in the list) + 1 * 20 + 2...

  • please help me with this question, thank you. Given the structure and pK, of aripiprazole (Aricept),...

    please help me with this question, thank you. Given the structure and pK, of aripiprazole (Aricept), select the predominant form in the gastric juice (pH 1.0) , that will not allow passage of the drug into the mucosal cell eytoplasm, 4. according to the pH partition theory. pans pK, 7.48 ఇ Pan Option Option I Option I Option V Option IV A. Option I B. Option II C. Option II D. Option IV E. Option V

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT