/* List structure: a nested set of objects. NOT an array.
Each object holds reference to its successor in the object chain. */
// Add a value to the front of a list (object chain)
// Use the list itself as input
function prepend(value, list){
return {value, rest:list};
};
console.log(prepend(10, prepend(20, null)));
// → {value: 10, rest: {value: 20, rest: null}}