Department of Computer Science
Principles of Functional Languages
Fall Semester 2010
Dr. Maury Eggen
Homework Laboratory Assignment One:
This homework assignment is a list management assignment. We shall explore
various functions involving lists.
- 1. (count ls) count all items in a (possibly nested) list
- 2. (sum ls) sum all items in a (possibly nested) list of numbers
- 3. (de-nest ls) de-nest takes any list, no matter how deeply nested and makes it into a flat list
- 4. (apnd lsa lsb) apnd hooks two lists together (can not use native append)
- 5. (remove-all item ls) remove-all removes all instances of an item from a (nested) list
- 6. (replace-all old new ls) replace-all replaces all instances of old-item with new-item in a (nested) list
- 7. (add-after a b ls) add-after adds a new item to a (nested) list after every occurrence of a given item
- 8. (add-before b a ls) add-before adds new item to a (nested) list before every occurrence of a given item
- 9. (add-beginning new ls) add-beginning adds a new item to the beginning of a (nested) list
- 10. (add-end new ls) add-end adds a new item to the end of a (nested) list
- 11. (wrap item n) wrap takes a given item and wraps it in parenthesis to
any level. For example, (wrap 10 5) would produce (((((10))))).
- 12. (rev ls) rev reverses the items in a list (may not use native reverse)
- 13. (iota n) iota produces a list of the numbers from 0 to (but not including) lits positive
integer argument.
Note: Important: you must use the function calls I have indicated
to name your functions. Provide a test function
that I can run which will 'exercise' all of the functions you submit.
I will be grading your homework electronically and will expect these
function names. More details in regarding requirements in class.
Homework due date: Friday, September 10, 2010. 26 points.