[Haskell-cafe] Longest increasing subsequence

Ariel J. Birnbaum valgarv at gmx.net
Thu Apr 10 20:25:24 EDT 2008

>   liss = maximumBy length . filter ascending . concat . map inits . tails
Of course my solution is braindamaged since I skipped this bit of the 
definition: [quote]Note that subsequence we are searching for is not 
necessarily contiguous[/quote]. Like the article says, without this detail 
the problem is quite trivial =P
	concat . map inits . tails
	foldr (\x xss -> xss ++ map (x:) xss) [[]] 

for a correct (yet even more inefficient) solution.
I'd blame the mistake on the late hour, but it was even later when I 
noticed... *shame*
Ariel J. Birnbaum

More information about the Haskell-Cafe mailing list