Lecture 8 Flashcards

1
Q

What is a tuple?

A

A data type similar to a record, but elements are not named.

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

How do you create a tuple in Python?

A

Using tuple literals: myTuple = (3, 5.8, ‘apple’).

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

How do you access the first element of a tuple in ML?

A

Using #1(myTuple).

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

How do you assign a tuple pattern in F#?

A

let a, b, c = tup.

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

How are lists represented in LISP and Scheme?

A

Delimited by parentheses, no commas: (A B C D).

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

What does the CAR function do in Scheme?

A

Returns the first element of its list parameter.

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

How do you add an element to a list in ML?

A

Using ::, e.g., 3 :: [5, 7, 9].

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

How are lists created in Python?

A

With assignments: myList = [3, 5.8, “grape”].

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

What is a union type?

A

A type whose variables can store different type values at different times.

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

What is a discriminated union?

A

A union type with a type indicator (discriminant) for type safety.

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

How does Ada ensure type safety in unions?

A

By using discriminants in record definitions.

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

What are the fundamental operations for pointers?

A

Assignment and dereferencing.

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

What is a dangling pointer?

A

A pointer that references a deallocated heap-dynamic variable.

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

How does Java handle pointers?

A

Java replaces pointers with references to ensure safety.

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

What is type checking?

A

Ensuring that operands of an operator are of compatible types.

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

What is strong typing in programming languages?

A

A feature where type errors are always detected.

17
Q

What is name type equivalence?

A

Types are equivalent if declared with the same name.

18
Q

What is structure type equivalence?

A

Types are equivalent if their structures are identical.