evm v0.1.2 EVM.Helpers
Various helper functions with no other home.
Link to this section Summary
Functions
Gets the byte at position pos
in binary
Helper function to print an instruction message
Inverts a map so each key becomes a value, and vice versa
Link to this section Functions
Gets the byte at position pos
in binary.
Examples
iex> EVM.Helpers.binary_get(<<1, 2, 3, 4>>, 2)
3
iex> EVM.Helpers.binary_get(<<1, 2, 3, 4>>, 4)
** (ArgumentError) argument error
Link to this function
inspect(msg, prefix)
Helper function to print an instruction message.
Inverts a map so each key becomes a value, and vice versa.
Examples
iex> EVM.Helpers.invert(%{a: 5, b: 10})
%{5 => :a, 10 => :b}
iex> EVM.Helpers.invert(%{dog: "cat"})
%{"cat" => :dog}
iex> EVM.Helpers.invert(%{cow: :moo})
%{moo: :cow}
iex> EVM.Helpers.invert(%{"name" => "bob"})
%{"bob" => "name"}
iex> EVM.Helpers.invert(%{})
%{}