Section 12 Chapter 69 - Functional Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Programming Paradigm

A

A style of computer programming e.g. OOP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Procedural

A

Series of instructions that tell the computer what to do

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Declarative

A

Written statements are implemented in a way that the programming language deems most appropriate

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Functional programming

A

Functions are the building blocks of the program. Statements are written as a series of functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Function

A

A rule or set of rules that maps values from the domain to the co-domain. A value from the domain is input tot the function and it returns a value from the co-domain

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What do the domain and co-domain have in common (in terms of sets)

A

They are both subsets of objects in some data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Domain

A

The set from which the functions input values are chosen

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Co-Domain

A

The set from which the functions outputs are chosen. Not all the members of the co-domain need to be outputs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Can the domain and co-domain be of different data types

A

yessir

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Function type

A

A -> B, where A is the argument type and B is the result type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Argument type

A

The data type of an argument of a function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Result type

A

The data type of the output of a function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

First class object (4)

A

An object which can

  • Appear in expressions
  • Be assigned to a variable
  • Be assigned as an argument
  • Be returned by a function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the cool first class object in functional programming

A

functions!!1!!11 :O

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the significance of functions being first class objects

A

They can be passed as an argument or returned by a function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Function Application

A

A function applied to its arguments

17
Q

Whats special about functional programming (2)

A
  • Statelessness

- No side effects

18
Q

Statelessness

A

Variables are immutable - their value cannot change

19
Q

No side effects

A

The only thing that a function can do is calculate something and return a result. Since the value of variables cannot change a function will always return the same output for the same input

20
Q

Composition of functions

A

Since functions can be used as an argument, multiple functions can be combined to create a new function

21
Q

Type

A

A set of values e.g. Integer, Float

22
Q

Typeclass

A

A set of types e.g. Num, which contains Integer, Float…