tensor v2.0.0 Tensor.Tensor.Helper
Link to this section Summary
Functions
Returns the keywise difference of two maps.
So: Only the part of map_a
is returned that has keys not in map_b
Returns the keywise difference of two maps.
So: Only the part of map_a
is returned that has keys also in map_b
Puts val
under map
inside a nested map indicated with keys
.
This is required, as the normal put_in
will fail if one of the levels
indicated by keys
is not initialized to a map yet
Swaps the element at position pos_a
with the element at position pos_b
inside a list
Link to this section Functions
Returns the keywise difference of two maps.
So: Only the part of map_a
is returned that has keys not in map_b
.
Examples:
iex> Tensor.Helper.map_difference(%{a: 1, b: 2, c: 3, d: 4}, %{b: 3, d: 5})
%{a: 1, c: 3}
Returns the keywise difference of two maps.
So: Only the part of map_a
is returned that has keys also in map_b
.
Examples:
iex> Tensor.Helper.map_intersection(%{a: 1, b: 2, c: 3, d: 4}, %{b: 3, d: 5})
%{b: 2, d: 4}
Puts val
under map
inside a nested map indicated with keys
.
This is required, as the normal put_in
will fail if one of the levels
indicated by keys
is not initialized to a map yet.
Examples:
iex>put_in_path(%{}, [1,2,3], 4) %{1 => %{2 => %{3 => 4}}}
Swaps the element at position pos_a
with the element at position pos_b
inside a list.
Examples
iex> swap_elems_in_list([1,2,3,4,5], 1, 3) [1, 4, 3, 2, 5]