Skip to content
UoL CS Notes

Home

This website houses notes from my studies at the University of Liverpool. If you see any errors or issues, please do open an issue on this site's GitHub.

Functions - 1

COMP109 Lectures

Basics and Definitions A function is a method that takes an input value and gives an output value: graph LR x -->|Input| F[Function Machine] F -->|Output| fx A function from a set $A$ to a set $B$ is an assignment of exactly one element of $B$ to each element of...

Read More

Russell's Paradox

COMP109 Lectures

Why is this set theory “Naive”? The reason is that is suffers from paradoxes. A barber is the man who shaves all those, and only those, men who do not shave themselves. Who shaves the barber? This statement and question form a paradox. As yet we know that you should...

Read More

Cardinality of Sets

COMP109 Lectures

The cardinality of a set is the number of elements in the set. The notation for this is $\vert A\vert$ where $A$ is a set to be counted. Power Set and Bit Vectors We use the correspondence between bit vectors and subsets: $\left\vert \textit{Pow}(A)\right\vert$ is the number of bit vectors...

Read More

Tutorial 4

COMP109 Tutorials

For the following questions: $\emptyset \in\{\text{Leeds, Liverpool}\}$ False $\emptyset \subseteq\{\text{Leeds, Liverpool}\}$ True $\emptyset = \{\}$ False as they are different types.

Read More

Lecture 14-3

COMP105 Lectures

Anonymous Functions Sometimes is it convenient to define a function inline. Anonymous functions allow you to use a function without a name. > (\ x -> x + 1) 7 > 8 This allows you to pass functions to a higher order function without giving it a name: > apply_twice...

Read More

Lecture 14-2

COMP105 Lectures

Higher Order Functions A higher order function is a function that: Takes another function as an argument. Returns a function. apply_twice :: (a -> a) -> a -> a apply_twice f input = f (f input) > apply_twice tail [1,2,3,4] > [3,4] This function takes a function and an input...

Read More

Lecture 14-1

COMP105 Lectures

More Type Classes show This function converts other types to strings. However, it can only take the type class of Show into a string: show :: Show a => a -> a Show contains: All basic types. All tuples of show-able types. All lists of show-able types. read This converts...

Read More

Catch-up Session 5

COMP109 Catch-up+Sessions

Example 1 $A=\{1,2,7,8,9\}, B=\{x\in A\vert x \text{ is odd}\}$ Where: $C=A-B=A\cap B$ Therefore: $B=\{1,7,9\}$ $C=\{2,8\} = \{x\in A \vert x \notin B\}$ Proving Identities To prove an identity you would consider the sections of a Venn diagram and consider each of the four cases. These cover all of the locations...

Read More

Seminar 4

COMP107 Seminars

Introducing assignment 4. Activities Identification of Application areas and users groups Analysis of existing documentation of application areas Analysis of current operating environments and the planned use of the information Information flow Types of transactions Responses to user questionnaires are analysed. As a result you should start form a place...

Read More

Lecture 13-2

COMP105 Lectures

Type Classes Some functions are polymorphic, but can’t be applied to any type. + is a good example. It can work on float and integer but not on mixed types or Char. The type of + is: (+) :: Num a => a -> a -> a This means that...

Read More