-
Notifications
You must be signed in to change notification settings - Fork 1
/
P93632.hs
29 lines (25 loc) · 1.59 KB
/
P93632.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
------------------------------------------------------------------------------------
--------------------------------------- EQL ----------------------------------------
------------------------------------------------------------------------------------
eql :: [Int] -> [Int] -> Bool
eql l1 l2 = and (zipWith (==) l1 l2) && length l1 == length l2
------------------------------------------------------------------------------------
--------------------------------------- PROD ---------------------------------------
------------------------------------------------------------------------------------
prod :: [Int] -> Int
prod array = foldl (*) 1 array
------------------------------------------------------------------------------------
------------------------------------ PRODOFEVENS -----------------------------------
------------------------------------------------------------------------------------
prodOfEvens :: [Int] -> Int
prodOfEvens array = prod $ filter even array
------------------------------------------------------------------------------------
------------------------------------- POWERSOF2 ------------------------------------
------------------------------------------------------------------------------------
powersOf2 :: [Int]
powersOf2 = iterate (*2) 1
------------------------------------------------------------------------------------
----------------------------------- SCALARPRODUCT ----------------------------------
------------------------------------------------------------------------------------
scalarProduct :: [Float] -> [Float] -> Float
scalarProduct l1 l2 = sum $ zipWith (*) l1 l2