17 Mar
2005
17 Mar
'05
4:34 a.m.
On 2005-03-16 02:52:39 -0800, Nicolas Oury <Nicolas.Oury@lri.fr> said:
instance Splittable Integer where split n = (2*n,2*n+1)
foo::(%x::Integer) => [a] -> [(a,Integer)] foo [] = [] foo (a:l) = (a,%x):(foo l)
test = let %x = 1 in foo [1..15000]
But, in this example, the numbering is linear and so test becomes quadratic. The main complexity of the program come from the numbering... (When you test it with ghci, this example is really slow)
I haven't played much with the Splittable class yet, but what would be wrong with instance Splittable Integer where split n = (n,n+1) ? -- Peter Davis <pediddle@pediddle.net> "Furthermore, I believe bacon prevents hair loss!"