function - List of lists, take next element -


i have [[integer]] -> [integer] , want take first element of first sub-list, second element of second sub-list , .. n-th element of n-th sub-list , on.

i trying achieve using list comprehensions. however, first drop incrementing number of elements , take head of remaining. there again don't know how use drop (inc z) z = 0 inc c = c + 1 defined function, in presumably this:

getnext :: [[integer]] -> [integer] getnext xs = [y | drop (inc z) (y:ys) <- xs, (y:_) <- xs]            z = 0 

i know code above not working, again had far come , hit wall.

you can this:

getnext :: [[a]] -> [a] getnext xs = [ head $ drop y x | (x,y) <- zip xs [0..]] 

although note function partial because of head.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -