
14 Apr
2009
14 Apr
'09
5:16 a.m.
Let's see, if I execute it by hand: cinits :: [a] -> [[a]] cinits [] = [[]] cinits (x:xs) = [] : map (x:) (cinits xs) cinits [1,2,3] = [] : map (1:) ( [] : map (2:) ( [] : map (3:) ( [[]]) ) ) = [] : map (1:) ( [] : map (2:) ( [] : map (3:) [[]] ) ) = [] : map (1:) ( [] : map (2:) ( [] : [[3]] ) = [] : map (1:) ( [] : map (2:) ( [[], [3]] ) = [] : map (1:) ( [] : [[2], [2,3]]) = [] : map (1:) ( [[], [2], [2,3]]) = [[],[1], [1,2], [1,2,3]] Well, I understand this part. But isn't there an easier way to "see" the answer? Thank you for your help!