CS-205 Haskell

studied byStudied by 33 people
5.0(1)
learn
LearnA personalized and smart learning plan
exam
Practice TestTake a test on your terms and definitions
spaced repetition
Spaced RepetitionScientifically backed study method
heart puzzle
Matching GameHow quick can you match all your cards?
flashcards
FlashcardsStudy terms and definitions
Get a hint
Hint

head

1 / 60

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

61 Terms

1

head

select first item of a list

New cards
2

tail

remove first item from a list

New cards
3

[ ] !! n

select the nth element from the list

New cards
4

take n

select the first n elements of a list

New cards
5

drop n

remove the first n elements of a list

New cards
6

length

calculate the length of a list

New cards
7

sum

calculate the sum of a list of numbers

New cards
8

product

calculate product of a list of numbers

New cards
9

++

append two lists

New cards
10

reverse

reverses a list

New cards
11

`div`

back quotes used for division

New cards
12

:reload / :r

reloads file

New cards
13

:load name

loads script name

New cards
14

:edit name

edit script name

New cards
15

:edit

edit current script

New cards
16

:type expr

show type of expr

New cards
17

:?

show all commands

New cards
18

:quit

quit GHCi

New cards
19

_

wildcard pattern, matches any argument value

New cards
20

Num

numeric types

New cards
21

Eq

equality types

New cards
22

Ord

ordered types

New cards
23

Int

fixed position integers

New cards
24

Integer

arbitrary precision integers

New cards
25

list

sequence of values of the same type

New cards
26

tuple

sequence of values of different types

New cards
27

function

a mapping from values of one type to values of another type

New cards
28

curried function

return functions as results, take arguments one at a time

New cards
29

polymorphic functions

if its type contain one or more type variable

New cards
30

overloaded

if its type contains more than one class constraint

New cards
31

higher-order

function that takes a function as an argument

New cards
32

\

lambda

New cards
33

(.)

returns composition of two functions as a single function

New cards
34

all

decides if every list element satisfies a given predicate

New cards
35

any

decides if at least one list element satisfies a predicate

New cards
36

takeWhile

selects elements from a list while a predicate holds all elements

New cards
37

dropWhile

removes elements while a predicate holds all elements

New cards
38

(1+)

successor function

New cards
39

(1/)

reciprocation function

New cards
40

(*2)

doubling function

New cards
41

(/2)

halving function

New cards
42

Zip

maps two lists to a list of pairs of their corresponding elements

New cards
43

string

sequence of characters

New cards
44

()

tuple with no components

New cards
45

getChar :: IO Char

reads characters from keyboard and returns it

New cards
46

putChar :: Char -> IO()

writes character to the screen

New cards
47

>>=

combinators

New cards
48

Steps of verification

1) give a formal specification of the desired property of the program
2) give a proof that the program meets the specification for all inputs

New cards
49

P(n)

invariant of a function

New cards
50

logic programming

prolog

New cards
51

functional programming

haskell

New cards
52

Map

applies a function to every element of a list

New cards
53

filter

selects every element from a list that satisfies a predicate

New cards
54

foldr

simultaneously replacing : in a list by a given function and [ ] by a given value

New cards
55

concat

concatenates a list of lists

New cards
56

type

name for a collection of related values

New cards
57

How can interactive programs be written in Haskell

using types to distinguish pure expressions from impure actions that may involve side effects

New cards
58

Why are type declarations made?

can make other types easier to read

New cards
59

Why are higher-order functions useful?

- Common programming idioms can we written as functions in the language
- Domain specific languages can be defined with appropriate collections of higher order functions
- We can use algebraic properties of higher order functions to reason about programs

New cards
60

Why is flodr useful?

- some recursive functions on lists, such as sum are simpler to define using foldr
- properties of functions defined using foldr can be proved using its algebraic properties
- advanced program optimisations can be simpler if foldr is used in place of explicit recursion

New cards
61

type variables

can be instantiated to different types in different circumstances

New cards
robot