Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

equality 5 == 5

not equal 5 /=5


&& bool and
|| bool or
infix sandwich funcs
prefix normal
min, max
92 `div` 10
let a = 1
let lostnumbers = [4,5,6,7,8,9]
++ concatenates two liststo add []
: concatenates item but on lhs list
[[],[],[]]
1. ghci> "Steve Buscemi" !! 6
2. 'B'
3. ghci> [9.4,33.2,96.2,11.2,23.25] !! 1
4. 33.2
5. ghci> let b = [[1,2,3,4],[5,3,3,3],[1,2,2,3,4],[1,2,3]]
6. ghci> b
7. [[1,2,3,4],[5,3,3,3],[1,2,2,3,4],[1,2,3]]
8. ghci> b ++ [[1,1,1,1]]
9. [[1,2,3,4],[5,3,3,3],[1,2,2,3,4],[1,2,3],[1,1,1,1]]
10.
ghci> [6,6,6]:b
11.
[[6,6,6],[1,2,3,4],[5,3,3,3],[1,2,2,3,4],[1,2,3]]
12.
ghci> b !! 2
13.
[1,2,2,3,4]
Lists are compared in a lexographical order, first head then 2 nd elem etc
Head [5,3,2,4,6]=5
Tail [5,3,2,4,6]=[ 3,2,4,6]
Last [5, 3,2,4,6]=6
Init [5,3,2,4,6]=[3,2,4,6]=
Length [5,3,2,4,6]=5
Null or xs==[]

Reverse []
Take 1 [1,2]
Maximum
Minimum
Sum
Product
`elem` if a list has something
[1..20]
[a..z]

take 24 [13,26..]

1.
2.
3.
4.

ghci> take 10 (cycle [1,2,3])


[1,2,3,1,2,3,1,2,3,1]
ghci> take 12 (cycle "LOL ")
"LOL LOL LOL "

take 10 (repeat 5)
take 10 [2,4..]
[x*2 | x <- [1..10]]

['h','e','l','l','o']

You might also like