CS-205 Haskell

5.0(1)
studied byStudied by 37 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/60

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 2:55 AM on 12/30/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

61 Terms

1
New cards

head

select first item of a list

2
New cards

tail

remove first item from a list

3
New cards

[ ] !! n

select the nth element from the list

4
New cards

take n

select the first n elements of a list

5
New cards

drop n

remove the first n elements of a list

6
New cards

length

calculate the length of a list

7
New cards

sum

calculate the sum of a list of numbers

8
New cards

product

calculate product of a list of numbers

9
New cards

++

append two lists

10
New cards

reverse

reverses a list

11
New cards

`div`

back quotes used for division

12
New cards

:reload / :r

reloads file

13
New cards

:load name

loads script name

14
New cards

:edit name

edit script name

15
New cards

:edit

edit current script

16
New cards

:type expr

show type of expr

17
New cards

:?

show all commands

18
New cards

:quit

quit GHCi

19
New cards

_

wildcard pattern, matches any argument value

20
New cards

Num

numeric types

21
New cards

Eq

equality types

22
New cards

Ord

ordered types

23
New cards

Int

fixed position integers

24
New cards

Integer

arbitrary precision integers

25
New cards

list

sequence of values of the same type

26
New cards

tuple

sequence of values of different types

27
New cards

function

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

28
New cards

curried function

return functions as results, take arguments one at a time

29
New cards

polymorphic functions

if its type contain one or more type variable

30
New cards

overloaded

if its type contains more than one class constraint

31
New cards

higher-order

function that takes a function as an argument

32
New cards

\

lambda

33
New cards

(.)

returns composition of two functions as a single function

34
New cards

all

decides if every list element satisfies a given predicate

35
New cards

any

decides if at least one list element satisfies a predicate

36
New cards

takeWhile

selects elements from a list while a predicate holds all elements

37
New cards

dropWhile

removes elements while a predicate holds all elements

38
New cards

(1+)

successor function

39
New cards

(1/)

reciprocation function

40
New cards

(*2)

doubling function

41
New cards

(/2)

halving function

42
New cards

Zip

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

43
New cards

string

sequence of characters

44
New cards

()

tuple with no components

45
New cards

getChar :: IO Char

reads characters from keyboard and returns it

46
New cards

putChar :: Char -> IO()

writes character to the screen

47
New cards

>>=

combinators

48
New cards

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

49
New cards

P(n)

invariant of a function

50
New cards

logic programming

prolog

51
New cards

functional programming

haskell

52
New cards

Map

applies a function to every element of a list

53
New cards

filter

selects every element from a list that satisfies a predicate

54
New cards

foldr

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

55
New cards

concat

concatenates a list of lists

56
New cards

type

name for a collection of related values

57
New cards

How can interactive programs be written in Haskell

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

58
New cards

Why are type declarations made?

can make other types easier to read

59
New cards

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

60
New cards

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

61
New cards

type variables

can be instantiated to different types in different circumstances

Explore top flashcards