[Haskell-cafe] efficient data structure: column with repeating values

Petr P petr.mvd at gmail.com
Wed Dec 19 07:32:53 CET 2012


Hi,

just an idea (using Seq from Data.Seq and Map from Data.Map):

> newtype DataTable a b = DataTable (Map b (Seq a))

or if you know you won't have repeated values, you could have

> newtype DataTable a b = DataTable (Map b (Set a))

Both those ideas sort the data (partially or fully). If you need to
preserve the ordering, you could do something like

> new DataTable a b = DataTable (Seq (a, Seq b))

Best regards,
Petr Pudlak


2012/12/19 Christopher Howard <christopher.howard at frigidcode.com>

> Is there some good data type out there that basically provides a simple
> table, but with optimization for repeating values on one column?
> Something like:
>
> Data Table a b
>
> ...where it assumes that 'a' values will usually be unique, while 'b'
> values will usually be repeated from a small set? (But not needing to be
> fixed beforehand.)
>
> Like in...
>
> client | patron
> ---------------
> Bob    | Tom
> Sarah  | Tom
> Dick   | Tom
> George | Harry
> Moe    | Harry
>
> --
> frigidcode.com
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121219/03c168dc/attachment.htm>


More information about the Haskell-Cafe mailing list