Basic recursion
Powerlist Powerplay
These exercises are going to see how you fair with basic recursive functions over lists.
-
Write a function that finds the length of a list
-
Write a function that sums up a list of numbers
-
Write a function that adds
4
to every element of[2, 3, 4, 5]
-
Write a function that finds the average of a list of numbers (Hint: this function isn’t in itself recursive, but uses ones that are)
-
Write a function that returns every 2nd element in a list
-
Write a function which finds the length of each list in a list of lists i.e. f [[1,2,3,4],[5,6],[7]] = [4,2,1]
-
Write a function that splits a list into the first three elements and the rest i.e. f [1,2,3,4,5,6,7,8,9] = ([1,2,3],[4,5,6,7,8,9])
-
Write a function that splits a list in blocks of 3. i.e. f [1,2,3,4,5,6,7,8,9] = [[1,2,3],[4,5,6],[7,8,9]]
-
Write a function which checks if a list of booleans are all false.
-
Write a function which checks if a list of a list of booleans are all false.
-
Write a function which checks if a list contains duplicates
-
Write a function that gets the element at the i’th index
-
Write a function that returns the last element of a list
-
Write a function that returns an infinite list of type
a
-
Write a function that returns n many elements from the end of a list (Hint: use the length function)
-
Write a funciton that returns the 2nd last element of a list
-
Write a function that returns a reversed list
-
Write a funciton that determines whether a list is a palindrome
-
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.