forked from steger/pr3-sose2026
list operations assignment
parent
256670a48f
commit
147f288142
|
|
@ -0,0 +1,10 @@
|
||||||
|
# Assignment
|
||||||
|
|
||||||
|
You are provided with:
|
||||||
|
|
||||||
|
1. A vector of names
|
||||||
|
2. A vector of ages
|
||||||
|
|
||||||
|
Your task is to compute a list containing the UPPERCASE names of the two oldest persons whose names ends with an "a". The result shall be sorted by alphabet.
|
||||||
|
|
||||||
|
Complete the corresponding unit test in the file `02-list-operations/list-operations.hs`.
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
|
||||||
|
|
||||||
|
{-# HLINT ignore "Avoid reverse" #-}
|
||||||
|
{-# HLINT ignore "Use void" #-}
|
||||||
|
|
||||||
|
import Data.Char (toUpper)
|
||||||
|
import Data.List (sort, sortOn)
|
||||||
|
import Test.HUnit
|
||||||
|
|
||||||
|
names = ["Oliver", "Emma", "Liam", "Ava", "Noah", "Sophia", "James", "Mia", "Elijah", "Isabella"]
|
||||||
|
|
||||||
|
ages = [25, 30, 22, 29, 35, 28, 40, 26, 33, 31]
|
||||||
|
|
||||||
|
-- we are looking for the UPPERCASE names of the two oldest persons whose names ends with an a sorted alphabetically"
|
||||||
|
|
||||||
|
extractedNames = []
|
||||||
|
|
||||||
|
test1 = Test.HUnit.TestCase (assertEqual "ExtractedNames" ["EMMA", "ISABELLA"] extractedNames)
|
||||||
|
|
||||||
|
tests = TestList [test1]
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = runTestTT test1 >> return ()
|
||||||
Loading…
Reference in New Issue