View Source IO.ANSI.Table.Spec.Rows (IO ANSI Table v1.0.34)

Derives the rows of a table. Also transposes rows into columns.

Summary

Functions

Derives the rows of a table given spec and maps.

Transposes rows into columns.

Functions

Link to this function

derive_and_put(spec, maps)

View Source
@spec derive_and_put(IO.ANSI.Table.Spec.t(), [Access.container()]) ::
  IO.ANSI.Table.Spec.t()

Derives the rows of a table given spec and maps.

Examples

iex> alias IO.ANSI.Table.Spec.Rows
iex> alias IO.ANSI.Table.Spec
iex> spec = Spec.new([:c4, :c1, :c2])
iex> maps = [%{c1: 11, c2: 12, c4: 14}, %{c1: 21, c2: 22, c4: 24}]
iex> %Spec{rows: rows} = Rows.derive_and_put(spec, maps)
iex> rows
[["14", "11", "12"], ["24", "21", "22"]]
@spec transpose([IO.ANSI.Table.Row.t()]) :: [IO.ANSI.Table.Column.t()]

Transposes rows into columns.

Examples

iex> alias IO.ANSI.Table.Spec.Rows
iex> rows = [
...>   ["1", "2", "3"],
...>   ["4", "5", "6"]
...> ]
iex> Rows.transpose(rows)
[["1", "4"], ["2", "5"], ["3", "6"]]