1
0
Fork 0

list operations assignment

main
Sebastian Steger 2025-08-20 15:11:10 +02:00
parent 256670a48f
commit 147f288142
2 changed files with 33 additions and 0 deletions

View File

@ -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`.

View File

@ -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 ()