Re: [Haskell-cafe] Producing MinimumValue

2007-07-19 Thread Colin DeVilbiss
On 7/19/07, Alexteslin [EMAIL PROTECTED] wrote: What wrong with my original solution? allEqual2 :: [Int] - Bool allEqual2 xs = length xs == length (filter isEqual xs) where isEqual n = (head xs) == n It looks simpler to me I believe it's correct, but the use of length and

Re: [Haskell-cafe] Construct all possible trees

2007-06-12 Thread Colin DeVilbiss
) (Leaf 3)) (Leaf 1), If I'm guessing the desired output correctly, this must be a typo? I'd be tempted to solve the list-only problem first (generate all sub-permutations of a list), then solve the tree problem (generate all un-flattenings of a list). Colin DeVilbiss

Re: [Haskell-cafe] k-minima in Haskell

2007-04-13 Thread Colin DeVilbiss
On 4/13/07, Ian Lynagh [EMAIL PROTECTED] wrote: Tuple each element with its position: O(n) Find kth smallest element in linear time, as per [1]: O(n) Filter list for elements = kth smallest: O(n) Sort filtered list by position: O(k log k) map

Re: [Haskell-cafe] Default (or empty) values

2007-01-17 Thread Colin DeVilbiss
On 1/17/07, Max Vasin [EMAIL PROTECTED] wrote: Fields of the Book datatype which are not (Maybe a) are required to be present. This doesn't actually answer your question, but if those fields are really required and you want to avoid the possibility of a default value sneaking into the program

Re: [Haskell-cafe] beginner's problem about lists

2006-10-10 Thread Colin DeVilbiss
On 10/10/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm trying to implement a function that returns the shorter one of two given lists, something like shorter :: [a] - [a] - [a] However, it becomes difficult when dealing with infinite lists, for example, shorter [1..5] (shorter [2..]

Re: [Haskell-cafe] List-to-outline

2006-02-14 Thread Colin DeVilbiss
by the hierarchies of its siblings. Is [0,2,1,2] invalid input? The behavior of both versions puts the first 2 and the 1 as children of the root, but the second 2 is a child of the 1. Colin DeVilbiss ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] class Ref...

2005-06-08 Thread Colin DeVilbiss
at Chris Okasaki's _Purely_Functional_Data_Structures_ (code available at his website). Pairing heaps and splay heaps (when bootstrapped) are said to have O(1) in everything but removeMin (new, insert, merge, findMin) and good constant factors. Colin DeVilbiss