Luke Palmer wrote: > Larry Evans wrote: >> >> contains a cross function which calculates the cross product >> of two lists. That attached does the same but then >> used cross on 3 lists. Naturally, I thought use of >> fold could generalize that to n lists; however, >> I'm getting error: > > The type of the function will not involve tuples, since they can be > arbitrary length (dynamic-length tuples are not supported in Haskell; > we use lists for that). > > cross :: [[a]] -> [[a]] > > ....
This is the sequence function from Control.Monad. cross :: [[a]] -> [[a]] cross = sequence > cross [[1,2],[3,4]] [[1,3],[1,4],[2,3],[2,4]] Regards, apfelmus _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe