
16 Mar
2005
16 Mar
'05
3:34 p.m.
On 2005-03-16 02:52:39 -0800, Nicolas Oury
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