1.0 Introduction Flashcards
What does {…} mean?
Used for procedure- and function calls
What des {Browse X} do?
Open browser window with content of X
Describe an Oz variable
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.
Describe an Oz function?
declare
fun {FunName X}
declare: Creates new variable FunName
fun: Statement, defines a function
FunName: Bound to this function
What is functional abstraction?
When functions are used to define other functions.
declare
fun {Fun2 X Y}
{Fun1 X Y}
end
Define lists in OZ
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
What is consing?
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
Describe Oz pattern matching
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
What is language semantics?
A mathematical model of the operations of a prorgamming language, defining what the operations should do
What is program specifications?
What a program should do.
The mathematical definitions of input provided to the program and output it calculates..
How to declare local variables within if-else statements?
if condition then
// block
else L in
L = 5
end
What is a program’s time complexity?
Execution time as function of input size, up to a constant factor.
What is lazy evaluation?
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
What does <future> mean when returned by a Browse function?</future>
That the variable has a lazy function attached to it.
How can you access values returned from a lazy function?
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