haskell - Using map and filter function -


i can't figure out how implement map , filter function matrix. have suggestions satisfy these tests?

-- | matrix tests -- -- prop> mapmatrix (\a -> - 3) (mapmatrix (+ 3) x) == x -- -- >>> filtermatrix (< 3) matrix1 -- [[1,2],[2]]  -- >>> filtermatrix (> 80) [] -- []  -- >>> transpose' matrix2 -- [[1,4],[5,8]]   mapmatrix :: (a -> b) -> [[a]] -> [[b]] mapmatrix f [list] = [map f list]  filtermatrix :: (a -> bool) -> [[a]] -> [[a]] filtermatrix = undefined  transpose' :: [[a]] -> [[a]] transpose' = undefined  matrix1 = [[1 .. 10], [2 .. 20]]  matrix2 = [[1, 5], [4, 8]] 

some hints, not complete solution because sounds homework. mapmatrix , filtermatrix: write functions work on 1 row of matrix @ time, map onto list of rows. transpose': 1 way list comprehension applies !! operator lists of indices, , recursive function removes 1 row @ time input , adds 1 column @ time output.

is filtermatrix supposed return list of lists not valid matrix?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -