Ready to begin
No records have been processed. Start with Next step.
![[3,53] stores Rida’s CardNo and Physics mark. The first component is an identifier; the last is the chosen property.](/images/computational-thinking/week-5/id-mark-pair.png)
Follow one occurrence at a time. Choose another input to test empty lists, repeated IDs and different parameters.
Ready
No records have been processed. Start with Next step.
Predict the next change, then step through the list. The original course records remain unchanged.
A list of marks alone loses the owners of those marks. A pair such as [3,53] keeps one identifier beside one property. A list of pairs keeps that connection for every selected record: [[0,64],[1,45],[2,54],…] for Physics in the original dataset order.
Pairs = []
foreach X in ScoreRecords:
Entry = [X.CardNo, X.Physics]
Pairs = Pairs ++ [Entry]
foreach Pair in Pairs:
ID = first(Pair)
Mark = last(Pair)A pair is a list of exactly two components. Its order has a schema: [ID,mark] differs from [mark,ID]. first(Pair) is the identifier and last(Pair) the mark only because we agreed on this schema. A pair can also hold an ID and a city string; components need not all be numeric.
This is a projection: keep relevant fields and leave out the rest. The resulting list is enough for tasks about the retained property and IDs, but not for questions about fields you omitted. Keep the original dataset available if later tasks may need birthdays, cities or other subjects.
Why is [3,53] not the same as [[3,53]]?
The first is a two-element pair. The second is a one-element outer list whose element is that pair.
What information does [3,53] lose compared with the full score card?
It omits fields such as Name, birthday, city, Maths, Chemistry and Total. The ID can reconnect to them only if the source lookup remains available.
How long is a 30-student list of [ID,Physics] pairs?
The outer length is 30. Each pair has length 2.