Exercises part 3
-
Here is a function declaration for flattening a
ListofLists:flattenList : List (List a) -> List aImplement
flattenListand declare and implement a similar functionflattenVectfor flattening vectors of vectors. -
Implement functions
take'andsplitAt'like in the exercises of the previous section but using the technique shown fordrop'. -
Implement function
transposefor converting anm x n-matrix (represented as aVect m (Vect n a)) to ann x m-matrix.Note: This might be a challenging exercise, but make sure to give it a try. As usual, make use of holes if you get stuck!
Here is an example how this should work in action:
Solutions.Dependent> transpose [[1,2,3],[4,5,6]] [[1, 4], [2, 5], [3, 6]]