---
# System prepended metadata

title: Reflection 4 – Data Abstractions 02C/03C

---

# Reflection 4 – Data Abstractions 02C/03C

Draw the box-and-pointer diagrams for the results of evaluating the following programs. Also write the data structures in box notation and in list notation.

# Need a whiteboard? Use https://r8.whiteboardfox.com/ and paste the link here.


```javascript

QUESTION ONE: TO PRESENT ON ZOOM (draw live)
/**
 * Group 1 – 1A
 * (a) pair(1, 2);
 * box notation: [1, 2]
 * list notation: NA
 * /https://r8.whiteboardfox.com/81515787-3670-9792



/**
 * Group 2 – 1B
 
 *(b) pair(1, pair(3, pair(5, null)));
 [1, [3, [5, null]]] / list(1, 3, 5)
//USE https://r8.whiteboardfox.com/81515794-6003-3867


/**
 * 1C – https://r8.whiteboardfox.com/81515535-0670-1241
 * */
 // pair(pair(pair(3, 2), pair(1, 0)), null);
 
/**
 * Group 3 – 1D
 * (a) pair(0, list(1, 2));
 * [0, [1, [2, null]]]
 * list(0, 1, 2)
 * https://r8.whiteboardfox.com/81515788-3302-2040
//USE https://r8.whiteboardfox.com/ and paste the link here.



/**
 * Group 4 – 2A
 * Write source programs that evaluate to values that are printed out in the source REPL as follows:
 * [1, [2, [3, null]]]
 * list(1, 2, 3);
 * OR
 * pair(1,pair(2,pair(3,null)));
 * 

/*
 * Group 5 – 2B
 * Write source programs that evaluate to values that are printed out in the source REPL as follows:
 *  [[1, [2, null]], [[3, [4, null]], [[5, [6, null]], null]]]
 *  
 */ 
list(list(1,2),list(3,4),list(5,6));

/*
3. Write programs that only use applications of head and tail and the name lst so that the result is 4:
*/

 // Group 6 – 3A
// (a) const lst = list(7, 6, 5, 4, 3, 2, 1);
head(tail(tail(tail(lst))));

// Group 7 - 3B 
// (b) const lst = list(list(7), list(6, 5, 4), list(3, 2), 1);

head(tail(tail(head(tail(lst)))))

tail(lst) -> [[6, [5, [4, null]]], [[3, [2, null]], [1, null]]]
head(tail(lst)) -> [6, [5, [4, null]]]
tail(head(tail(lst))) -> [5, [4, null]]
tail(tail(head(tail(lst)))) -> [4, null]
head(tail(tail(head(tail(lst))))) -> 4