haskell, function composition -


i need solve task on function composition in haskell. need write function given integer n , list of inner lists of elements, returns list of n-th element in each inner list. like: select 2 [[2,3,4],[5,6],[9,9,9]] = [3,6,9]. thing is, need write using function composition should select = .... in other words, want make point-free.

for now, have following:

select::int->[[int]]->[int] select = map $ head. reverse. take  

i'm stuck it, don't know how remove a first , clause. can me this?:)

based on have, can use select = map . ((head . reverse) .) . take, simplify select = map . (last .) . take. alternative use select = map . flip (!!) . subtract 1.

you can use pointfree package derive pointfree versions of functions automatically.

generally advise against though. functions have multiple parameters become quite obfuscated when defined in pointfree style.


Comments