我有這樣的代碼,這是組合的公式,而重複:哈斯克爾,返回一個元組
combinaciones :: Int ->[Int]->[[Int]]
combinaciones 0 _ = [[]]
combinaciones _ [] = []
combinaciones k (x:xs) = [x:ys | ys <- combinaciones (k - 1) xs] ++ combinaciones k xs
combinationsN :: Int ->Int->[[Int]]
combinationsN n k = combinaciones k [1..n]
我的問題是,我想返回一個列表的列表與列表中的列表中的號碼,一對夫婦:([[Int]],Int)。我怎樣才能做到這一點?
你正在尋找的詞是「元組」。 – 2013-05-01 23:04:24
是的!哈哈,你知道我該如何解決這個問題? :-( – mguedez 2013-05-01 23:05:26
這是教程級的材料:http://en.wikibooks.org/wiki/Haskell/YAHT/Language_basics#Pairs.2C_Triples_and_More – millimoose 2013-05-01 23:09:38