On Mon, Jan 17, 2005 at 08:54:38PM -0800, Ben Rudiak-Gould wrote:
> If performance is the main concern, I would flatten the data structure:
> 
>    data Interval = IlII Double Double
>                  | IlIE Double Double
>                  | IlEI Double Double
>                  | IlEE Double Double
>                  | NilII Double Double
>                  | NilIE Double Double
>                  | NilEI Double Double
>                  | NilEE Double Double

I would go even further 

>    data IntervalType = IlII 
>                  | IlIE 
>                  | IlEI 
>                  | IlEE 
>                  | NilII
>                  | NilIE
>                  | NilEI
>                  | NilEE
>    data Interval = Interval IntervalType {-# UNPACK #-} !Double {-# UNPACK 
> #-} !Double

now, the doubles can be stored in their native form and are not under a
union data type (which always must be represented by a pointer) so
accessing them can be very fast.

        John


-- 
John Meacham - ârepetae.netâjohnâ 
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to