lab04: init

This commit is contained in:
2026-02-09 12:14:20 -08:00
parent 802f99b8ba
commit b210cb5b32

25
lab04/mapFilter.hs Normal file
View File

@@ -0,0 +1,25 @@
-- USING MAP, convert a list of Strings to a list of Integers.
stringsToNums :: [String] -> [Integer]
-- USING MAP, take a list of integers and return a list with
-- the equivalent absolute values.
-- USING ZIPWITH, concatenate a list of first names with
-- a list of last names to produce a list of full names.
-- USING MAP AND FILTER, square all positive numbers in a list;
-- strip out 0 and negative numbers.
main :: IO ()
main = do
print $ stringsToNums []
print $ stringsToNums ["1", "2", "3", "4", "5"]
print $ mapAbsVal [-4, 3, 2, -99, 54]
print $ mapAbsVal $ stringsToNums ["-4", "7", "-22"]
print $ fullNames ["John", "Wes Happen", "Holly"] ["Smith", "Ng", "Wood"]
print $ squarePostives [2, -3, 45, 5, 0, 7, -6]