Interleave List of Lists in Haskell
问题 I was wondering how could I write a function in Haskell that interleaves a list of lists into a single lists, for example, if I had a function called interleavelists :: [[a]] -> [a] it should be able to interleave the elements. Example: [[1,2,3] [4,5,6] [7,8]] --> [1,4,7,2,5,8,3,6] . The lists can be both finite or infinite... Can I use foldr ? 回答1: The quickest way to write it is to use transpose from Data.List . import Data.List interleavelists :: [[a]] -> [a] interleavelists = concat .