Re: [Haskell-cafe] Dropping trailing nulls from a list of list

2006-03-08 Thread Henning Thielemann
On Wed, 8 Mar 2006 [EMAIL PROTECTED] wrote: Today, I reviewed a function I wrote a few months ago. The function, dropTrailNulls, takes a list of lists and drops trailing null lists. For instance: *Main> dropTrailNulls [[1],[2,3],[],[]] [[1],[2,3]] http://www.haskell.org/pipermail/libraries

Re: [Haskell-cafe] Dropping trailing nulls from a list of list

2006-03-08 Thread Bulat Ziganshin
Hello Jeff, Wednesday, March 8, 2006, 8:08:57 PM, you wrote: > dropTrailNulls list = reverse (dropWhile null (reverse list))  dropTrailNulls [] = [] dropTrailNulls ([]:xs) = case dropTrailNulls xs of                            [] -> []                            list -> []:list drop

Re: [Haskell-cafe] Dropping trailing nulls from a list of list

2006-03-08 Thread Udo Stenzel
[EMAIL PROTECTED] wrote: > > Today, I reviewed a function I wrote a few months ago. The function, > dropTrailNulls, takes a list of lists and drops trailing null lists. For > instance: > > *Main> dropTrailNulls [[1],[2,3],[],[]] > [[1],[2,3]] dropTrailNulls = foldr dtn [] where dtn [] []

Re: [Haskell-cafe] Dropping trailing nulls from a list of list

2006-03-08 Thread Robert Dockins
On Mar 8, 2006, at 12:08 PM, [EMAIL PROTECTED] wrote:Today, I reviewed a function I wrote a few months ago.  The function, dropTrailNulls, takes a list of lists and drops trailing null lists.  For instance: *Main> dropTrailNulls [[1],[2,3],[],[]] [[1],[2,3]] My original implementation was terribl

Re: [Haskell-cafe] Dropping trailing nulls from a list of list

2006-03-08 Thread Neil Mitchell
> dropTrailNulls list = reverse (dropWhile null (reverse list)) Or more succinctly: dropTrailNulls = reverse . dropWhile null . reverse > Or, is there a more efficient idiom for addressing these problems? The "bad thing" about this definition is that it is tail strict. Consider ["hello","every

[Haskell-cafe] Dropping trailing nulls from a list of list

2006-03-08 Thread Jeff . Harper
Today, I reviewed a function I wrote a few months ago.  The function, dropTrailNulls, takes a list of lists and drops trailing null lists.  For instance: *Main> dropTrailNulls [[1],[2,3],[],[]] [[1],[2,3]] My original implementation was terrible.  It was recursive, overly bulky, and difficult to