[ANN] agrid 0.1


I’m pleased to announce the first release of agrid.

Agrid stands for Adjustable Grid. Adjustable grids are basically two dimensional arrays whose width/height can be changed by adding or removing row/column at either end (one at a time).

Here’s a very short example :

let () =
  let grid = Agrid.of_list [[1; 2]; [3; 4]] in
  let grid = Agrid.snoc_row grid (Flex_array.of_list [5; 6]) in
  Agrid.pp Format.pp_print_int Format.std_formatter grid
  (* prints:
   * 1; 2
   * 3; 4
   * 5; 6

It’s based on the great flex-array library by Jean-Christophe Filliâtre and is mainly a wrapper around it to make it easier for the special case of two dimensional arrays.

It’s been developped at OCamlPro while working on mosaic when we wanted to ease the dataset input process, switching from a basic textarea based input to something which looks like a spreadsheet (this work is not yet published on the online version).

Enjoy !


Out of curiosity: In a spreadsheet, I would assume that inserting/removing rows or columns in the middle is also a useful operation. Would you be able to add this operation?

It’s not really a spreadsheet, it’s more something like this. I don’t think it would be really useful in the case of mosaic because for big inputs, users are more likely to import the data from a file.

Anyway, it’s possible to add this operation, but I can’t think of an efficient way to do it. I’ll think about it and may add such an operation. Actually, if it’s added to flex-array, it would be trivial to add it to agrid, so I’ll probably try to add it there.