package olinq

  1. Overview
  2. Docs

Module OLinq_tableSource

Generic-Purpose table

This table is designed for holding relational data over scalar values (strings, intergers, bools, etc.). It trades type-safety for flexibility, and should be well-suited to dealing with CSV-encoded data.

STATUS: EXPERIMENTAL

Sourcetype 'a printer = Format.formatter -> 'a -> unit
Sourcetype 'a sequence = ('a -> unit) -> unit

Scalar Value

Sourcetype data =
  1. | S of string
  2. | I of int
  3. | B of bool
  4. | F of float
Sourcemodule Data : sig ... end
Sourceval int : int -> data
Sourceval float : float -> data
Sourceval bool : bool -> data
Sourceval string : string -> data

A row of values

Sourcetype row = data array
Sourceexception IndexError
Sourcemodule Row : sig ... end

A Table, that is, an extensible list of Rows

Sourceexception DimError

Raised in case dimensions don't match

Sourcetype t
Sourceval create : ?size:int -> names:string array -> unit -> t

create ~names () creates a new table with columns labelled with names

Sourceval init : names:string array -> int -> (int -> row) -> t

init ~names n f makes a table with size rows, each initialized from f

  • raises DimError

    if some row returned by f doesn't have the same size as names

Sourceval make : names:string array -> int -> row -> t

init ~names n row makes a table with size rows, all equal to row

  • raises DimError

    if Row.size row <> length names

Sourceval num_rows : t -> int
Sourceval num_cols : t -> int
Sourceval size : t -> int

Alias to num_rows

Sourceval names : t -> string array

Access the column names. Should not be modified

Sourceval get : int -> t -> row option

get n tbl gets the n-th row

Sourceval get_exn : int -> t -> row
Sourceval get_cell : int -> int -> t -> data option

get_cell i j tbl gets the j-th value of the i-th row

Sourceval get_cell_exn : int -> int -> t -> data
Sourceval fold : f:('acc -> row -> 'acc) -> x:'acc -> t -> 'acc
Sourceval iter : f:(row -> unit) -> t -> unit
Sourceval iteri : f:(int -> row -> unit) -> t -> unit
Sourceval push : t -> row -> unit

Push a row into the table

  • raises DimError

    if the row has not the same dimension as table

Sourceval push_l : t -> row list -> unit
  • raises DimError

    if some row has not the same dimension as table

Sourceval push_seq : t -> row sequence -> unit
  • raises DimError

    if some row has not the same dimension as table

Sourceval to_seq : t -> row sequence
Sourceval to_list : t -> row list
Sourceval to_list_rev : t -> row list
Sourceval print : t printer