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
Post a Comment