codebytes: Displaying the contents of an arbitrarily complex nested list - Coding Interview Question
Write a function (in pseudo-code) called dumpList that takes as its parameters a string and a reference to an arbitrarily complex nested list and prints the value of each list element on a separate line. The value of each line should be preceded by the string and numbers indicating the depth and index of the element in the list. Assume that the list contains only strings and other nested lists.
Let's take a look at an example of what we want exactly in the dumpList function. Suppose that you are given the following nested list. A nested list is just a list that contains other lists as well – so in the list below you see that it also contains the lists ['a','b','c'] and ['eggs'] :
Read full article from codebytes: Displaying the contents of an arbitrarily complex nested list - Coding Interview Question
No comments:
Post a Comment