16. Recursion I:  Passing the Buck:  Problems

Last revision:  March 23, 1998

Author: YourNameGoesHere

Doubling

Use recursion to double each element in a list: "double[{1,2,3}]" should return "{2,4,6}".  Of course, don't multiply the list by 2.

Partitioning

Use recursion to partition a list:  "recurPartition[L_List,k_Integer]" should return the same thing as "Partition[L,k]".  Of course, don't use "Partition[]".

Counting Until Base Case

Use recursion to count how many times the argument can have its square root taken before the result is less than 2:  "manySqrt[x_Real]" should report how many times the "Sqrt[]" function has to be applied to "x" before the result is less than 2.  For instance, Sqrt[81.0] is 9.0, Sqrt[9.0] is 3.0 and Sqrt[3.0] is less than 2 so, "manySqrt[81.0]" is 3.  Of course, don't use a logarithm.

Summing a List

Use recursion to sum the elements of a list:  "addUp[{a,1,3,b}]" should return "4+a+b".  Of course, don't use "Plus[]" on a list.