Do the following programming exercises. You can put all the functions in the sam
ID: 3776998 • Letter: D
Question
Do the following programming exercises. You can put all the functions in the same Elm file. Write an Elm function sort3 that takes 3 integers and returns a 3-tuple with the values in descending order (i.e., largest first). Write an Elm function sumSqBig that takes 3 integers and returns the sum of the squares of the two larger integers. (You may use sort3.) Write a Elm function adjpairs that takes a polymorphic list and returns the list of all pairs of adjacent elements. For example, adjpairs [2, 1, 11, 4] returns [(2, 1), (1, 11), (11, 4)]. Write an Elm function mean that takes a list of numbers and returns the mean (i.e., average) value for the list. Write an Elm function merge that takes two increasing lists of integers and merges them into a single increasing list (without any duplicate values). A list is increasing if every element is less than (Explanation / Answer
Answer 2.
import Html exposing (text)
square n =
n^2
sumSqBig x y z =
if x >= z && y>=z then
square x + square y
else if x>=y && z>=y then
square x + square z
else
square y + square z
main =
text (toString (sumSqBig 1 3 4 ))
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.