-
Notifications
You must be signed in to change notification settings - Fork 0
/
tutorial.hs
64 lines (49 loc) · 936 Bytes
/
tutorial.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
-- This is a basic learning of Haskell
{- Lazy language:
Only evaluates what it needs.
-}
-- Imports
import Data.List
-- :: Bool
trueAndFalse = True && False
trueOrFalse = True || False
notTrue = not(True)
-- :: Int
maxInt = maxBound :: Int
-- :: Integer
numFive :: Integer
numFive = 5
-- :: Float
numFive' :: Float
numFive' = 5.0
boolFive :: Bool
boolFive = 5 < 4
-- :: Double
-- if not specified
myFloat = 1.0 + 2.5
myDouble = 3.0 + 1.0
myFloat' :: Float
myFloat' = 1.0 + 2.5
-- :: Char
myChar = 'a'
-- :: String
myString = "String"
-- Math
mySum = 2 + 3
myDiv = 6 / 3
mySub = 5 - 2
myMult = 3 * 6
myMod = 9 `mod` 3
-- pi, exp, log, sin
truncDouble = truncate myDouble
roundDouble = round myDouble
ceilDouble = ceiling myDouble
floorDouble = floor myDouble
mySqrt = sqrt myFloat
-- List
numList = [1,2,3,4]
rangeList = [1..5]
alphaList = ['a'..'z']
evenNums = [2,4..20]
oddNums = [1,3..15]
sumNumList = sum numList