List processing Flashcards

1
Q

What is a list?

A

A list is a data structure consisting of a list of data elements that are of the same data type and size; the list is named by an identifier and the data elements stored can be integers, real numbers, characters or text strings.

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

What is a head?

A

this is the first element of the list.

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

What is a tail?

A

this is all the other elements of the list apart from the head

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

What is the length?

A

this is the number of elements in the list.

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

What is an Empty List?

A

A list with no elements is termed an empty list and is shown using the symbols [ ]

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

What is the haskell head?

A

In Haskell, a list can be written in the form of head : tail

Therefore, the list [6, 4, 9, 12] can be written as 6 : [4, 9, 12]
where 6 is the head of the list and [4, 9, 12] is the tail

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

What is the return head of the list?

A

Returns the first element of the list (1) using the head command in Haskell

Example:
head [1, 2, 3, 4, 5, 6]
1

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

What is the return tail of the list?

A

Returns the all the other elements apart from the head (2, 3, 4, 5, 6) using the tail command in Haskell

Example:
tail [1, 2, 3, 4, 5, 6]
[2, 3, 4, 5, 6]

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

What is the test for empty list?

A

Returns False if the list being checked is not empty using the null command in Haskell
Example:
null [ ]
True

Returns False if the list being checked is not empty using the null command in Haskell
Example:
null [1, 2, 3, 4, 5, 6]
False

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

What is the return length of list

A

Returns how many elements are contained in a list (6) using the length command in Haskell

Example:
length [1, 2, 3, 4, 5, 6]
6

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

What is constructing lists?

A

Assign an empty ( [ ] ) list using the let command in Haskell,
Example:
let emptylist = [ ]
emptylist
[ ]

Assign a list ( [5, 6, 7, 8] ) using the let command in Haskell, as shown in the example
Example:
let mylist = [5, 6, 7, 8]
mylist
[5, 6, 7, 8]

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

What is prepend an item to a list?

A

Add a new element [1] to the beginning of the list
[5, 6, 7, 8],

Example:
[5, 6, 7, 8]
let mylist = [1] ++ [5, 6, 7, 8]
mylist
[1, 5, 6, 7, 8]

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

What is append item to a list?

A

Add a new element [9] to the end of the list

Example:
[5, 6, 7, 8]
let mylist = [5, 6, 7, 8] ++ [9]
mylist
[5, 6, 7, 8, 9]

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