Basic Recursion
Given a possibly nested sequence and an item, count the occurrences of the item in the sequence.
For instance given,
[1, [2, 3], 4, [5, [6, 4]]]
you should be able to count 2 occurrences of 4.
Use recursion.
Map a possibly nested sequence to its flattend version, which comprises only the ground element. For example, the sequence
[1, [2, 3], 4, [5, [6, 7]]]
should be mapped to
[1, 2, 3, 4, 5, 6, 7]
Use recursion.
Write a function that takes an object and a sequence and returns the index of the item in the sequence, starting from 0. If the item does not occur in the sequence, return -1.
Use recursion.
Given a set of items provided as a list, write a function that returns the power set of the given set.
Use recursion.
Given a possibly nested list, compute the deepest level of embedding in the list. The ground level counts as 0 depth. For example, the list T
[1, [2, 3], 4, [5, [6, 7]]]
should return 2.
Use recursion.