smallex v0.1.8 MapList

Map list library.

Link to this section Summary

Link to this section Functions

Link to this function columns_rows(columns, rows)
Link to this function columns_rows(columns, rows, atom)

Zip columns list and list of rows list

Examples

iex> MapList.columns_rows( [ "c1", "c2", "c3" ], [ [ "v1", 2, true ], [ "v2", 5, false ] ] )
[ %{ "c1" => "v1", "c2" => 2, "c3" => true }, %{ "c1" => "v2", "c2" => 5, "c3" => false } ]
iex> MapList.columns_rows( [ "c1", "c2", "c3" ], [ [ "v1", 2, true ], [ "v2", 5, false ] ], :atom )
[ %{ c1: "v1", c2: 2, c3: true }, %{ c1: "v2", c2: 5, c3: false } ]
Link to this function find(map_list, match_map, match_key)
Link to this function first_columns_after_rows(columns_rows, with_atom \\ :no_atom)

Zip columns list(first line) and list of rows list(after second lines)

Examples

iex> MapList.first_columns_after_rows( [ [ "c1", "c2", "c3" ], [ "v1", 2, true ], [ "v2", 5, false ] ] )
[ %{ "c1" => "v1", "c2" => 2, "c3" => true }, %{ "c1" => "v2", "c2" => 5, "c3" => false } ]
iex> MapList.first_columns_after_rows( [ [ "c1", "c2", "c3" ], [ "v1", 2, true ], [ "v2", 5, false ] ], :atom )
[ %{ c1: "v1", c2: 2, c3: true }, %{ c1: "v2", c2: 5, c3: false } ]
Link to this function make_empty_map_without_key(map_list, match_key, no_match_value)
Link to this function merge(base_map_list, add_map_list, match_key, no_match_value)

Outer join keys to map-list on same key-value pair from another

Examples

iex> MapList.merge( [ %{ "a" => "key1", "b" => 12 }, %{ "a" => "key2", "b" => 22 } ], [ %{ "a" => "key1", "c" => 13 }, %{ "a" => "key3", "c" => 23 } ], "a", "no_match" )
[ %{ "a" => "key1", "b" => 12, "c" => 13 }, %{ "a" => "key2", "b" => 22, "c" => "no_match" } ]
Link to this function no_match(base_map_list, match_map_list, match_key)
Link to this function replace(base_map_list, add_map_list, match_key)

Inner join keys to map-list on same key-value pair from another

Examples

iex> MapList.replace( [ %{ "a" => "key1", "b" => 12 }, %{ "a" => "key2", "b" => 22 } ], [ %{ "a" => "key1", "c" => 13 }, %{ "a" => "key3", "c" => 23 } ], "a" )
[ %{ "a" => "key1", "b" => 12, "c" => 13 }, %{ "a" => "key2", "b" => 22 } ]
Link to this function zip(list1, list2)
Link to this function zip(list1, list2, atom)

Zip two lists to map

Examples

iex> MapList.zip( [ "a", "b", "c" ], [ 1, 2, 3 ] )
%{ "a" => 1, "b" => 2, "c" => 3 }
iex> MapList.zip( [ "a", "b", "c" ], [ 1, 2, 3 ], :atom )
%{ a: 1, b: 2, c: 3 }