1.0 Introduction Flashcards

1
Q

What does {…} mean?

A

Used for procedure- and function calls

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

What des {Browse X} do?

A

Open browser window with content of X

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

Describe an Oz variable

A

Variables has 2 components, an identifier and a store variable.

Identifier: Name, start with uppercase letter

Store variable: Part of system’s memory. Declare creates a new store variable, and makes identifier point to it.

Must be declared.

Values are bound to variables. Once a variable is assigned a value, it can not change.

declare
A = 10

Variables later in the program can have the same name as a previous variable. In this case, the old value will be overwritten, and cannot be accessed again.

Variables/calculations done with the previous variable-value will remain the same. This is because the identifier just refers to a new store variable, not overwriting the previous one.

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

Describe an Oz function?

A

declare
fun {FunName X}

declare: Creates new variable FunName
fun: Statement, defines a function
FunName: Bound to this function

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

What is functional abstraction?

A

When functions are used to define other functions.

declare
fun {Fun2 X Y}
{Fun1 X Y}
end

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

Define lists in OZ

A

List contains 2 things:
- Head-element
- reference to the rest of the list (Tail-list)

Can create a list by adding Head-elements:
a = nil
b = 1|a
c = 2|b

Fetch list components:
L.1: Gives list head-element
L.2: Gives reference to rest of the list

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

What is consing?

A

Cons (or a pair): The link H|T

Consing: Creating a new link

If T is a list. Consing H and T creates the new list H|T

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

Describe Oz pattern matching

A

case List of H|T then S end

case: Declares 2 local variables and binds them to the Head and Tail of the list.

case decomposes the list List based on the pattern H|T

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

What is language semantics?

A

A mathematical model of the operations of a prorgamming language, defining what the operations should do

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

What is program specifications?

A

What a program should do.

The mathematical definitions of input provided to the program and output it calculates..

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

How to declare local variables within if-else statements?

A

if condition then
// block
else L in
L = 5
end

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

What is a program’s time complexity?

A

Execution time as function of input size, up to a constant factor.

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

What is lazy evaluation?

A

Only doing a calculation when the result is needed.

fun lacy {Count N}
N | {Count N+1}
end
lazy: function will only be evaluated when needed

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

What does <future> mean when returned by a Browse function?</future>

A

That the variable has a lazy function attached to it.

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

How can you access values returned from a lazy function?

A

Values will only be calculated when needed.

L = {Count N} // Here Count is a lazy function

{Browse L}: returns L<future></future>

{Browse L.1}: returns first element of L

case L of A|B|C|_ thn {Browse A + B + C} end

Here the first three values of L is needed, therefor they are calculated

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

What is higher order programming?

A

Functions that takes other functions as argument

declare
fun {HigherOrder Op X}
{Op X}
end

17
Q

What is concurrency?

A

When programs consist of several independent activities that operate at their own pace. The programmer specifies communication between these.

18
Q

What is a thread, and how are they created?

A

An executing program.

Program can contain multiple threads.

thread
{Browse ‘hello’}
end

19
Q

What is dataflow behaviour?

A

If a function tries to access a variable that is not yet bound, the program waits until this variable gets bound, maybe by another thread running.

20
Q

What is dataflow concurrency?

A

Programs with dataflow behaviour will always produce the same results, however operations and bounding is partitioned between threads.

As long as the same operations are performed, with the same arguments, their behaviour remains the same.

21
Q

What is an object and an objects interface?

A

A function with internal state.

The interface of an object is the functions defined within it.

declare
local C in
C = 1
fun {Fun1}
return 1
end
fun {Fun2}
return 2
end
end

22
Q

What is the difference between object based- and object oriented programming?

A

Both use classes and objects, but object-oriented also implement inheritance.

23
Q

What is nondeterminism?

A

Threads operate independently. Because of this they may operate in different orders in different program runs, leading to different program outputs (race condition)

24
Q

What does it mean that threads are interleaving?

A

They take turn executing a little bit of their programs at the time. Meaning, when one thread is scheduled, it may not run to completion, when the next is scheduled.