University of Arizona, Department of Computer Science

CSc 120: List to String (Recursive)

Expected Behavior

Write a recursive function list2string(arglist), where arglist is a list of strings, that returns the string resulting from concatenating the elements of arglist.

Programming Requirements

Solve this problem using recursion. You are allowed to use only the following programming constructs:

Solutions that go outside these constructs, e.g., by using for/while loops or list comprehensions, will not get credit.

Examples

  1. list2string(['aa','bb','cc','dd'])
    return value: 'aabbccdd'

  2. list2string(['aa','bb','','cc','','dd'])
    return value: 'aabbccdd'

  3. list2string(['aa'])
    return value: 'aa'

  4. list2string([])
    return value: ''

  5. list2string(['',''])
    return value: ''