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
) (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
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
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
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..]
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
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