-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.hs
More file actions
42 lines (26 loc) · 1.04 KB
/
test.hs
File metadata and controls
42 lines (26 loc) · 1.04 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
doubleMe x = 2*x
doubleUs x y = doubleMe x + doubleMe y
doubleSmallNumber x = if x > 100
then x
else x*2
-- ++ operator adds lists together, which also works with strings
addLists listOne listTwo = listOne ++ listTwo
-- : operator prepends an element to the list
prependElement element list = element:list
-- !! operator gives you an element with the respectful index
getByIndex index list = list !! index
-- head gives you the first element of a list
getHead list = head list
-- tails gives you a new list without the first element
getTail list = tail list
-- init gives you a new list without the last element
getInit list = init list
getLength list = length list
getReversed list = reverse list
-- take will give you a new list without the number of elements you want extract
extractElement toExtract list = take toExtract list
dropElement toDrop list = take toDrop list
getMin list = minimum list
getSum list = sum list
getProduct list = product list
isElem element list = element `elem` list