The following questions were adapted from Prolog Lists, and mostly re-written to remove any prolog references or examples.
- Find the last element of a list
- Find the last but one element of a list.
- Find the K'th element of a list.
- Find the number of elements of a list.
- Reverse a list.
- Find out whether a list is a palindrome.
A palindrome can be read forward or backward; e.g. [x,a,m,a,x]. - Flatten a nested list structure.
Transform a list, possibly holding lists as elements into a 'flat' list by replacing each list with its elements (recursively). - Eliminate consecutive duplicates of list elements.
If a list contains repeated elements they should be replaced with a single copy of the element. The order of the elements should not be changed. - Pack consecutive duplicates of list elements into sublists.
If a list contains repeated elements they should be placed in separate sublists. - Duplicate the elements of a list a given number of times.