Assuming you already think you know what cinits does, you can convince yourself using induction.
On Tue, Apr 14, 2009 at 11:16 AM, Tsunkiet Man <[email protected]> wrote: > 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! > _______________________________________________ > Haskell-Cafe mailing list > [email protected] > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
