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
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
ADVERTISEMENT