Do this in Haskell.
You MUST solve each problem using "map", "filter", "foldr", or
"foldl".
{-
Implement the "min2" function.
min2: takes a list of numbers,
returns the second-smallest number of the
input list
Note that if a list contains DUPLICATES, the second-smallest
number and the smallest number may be identical;
your code should return it.
We also assume that all input lists contain at least TWO
numbers.
Examples:
min2 [2110, 4820,
3110, 4120] == 3110
min2 [2110, 4820,
2110, 4120] == 2110
-}
min2 :: Ord a => [a] -> a
-- YOUR CODE START HERE
-- YOUR CODE END HERE
{-
Test your implementation: all following expressions should
return "True"
min2 [2110, 4820, 3110, 4120] == 3110
min2 [2110, 4820, 2110, 4120] == 2110
min2 [1.2, 2.3, 1.2, 1.2] == 1.2
-}
Do this in Haskell. You MUST solve each problem using "map", "filter", "foldr", or "foldl". {- Implement the "min2" func
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am