A.vec
You're seeing just the macro
vec
, go back to A module for more information.
Convenience macro to create or pattern match on A.Vector
s.
Examples
iex> import A
iex> vec([1, 2, 3])
vec([1, 2, 3])
iex> vec(first ||| last) = A.Vector.new(0..99_999); {first, last}
{0, 99999}
iex> vec([1, 2, var, _, _, _]) = A.Vector.new(1..6); var
3
iex> vec([_, _, _]) = A.Vector.new(1..6)
** (MatchError) no match of right hand side value: vec([1, 2, 3, 4, 5, 6])
It also supports ranges with constant values:
iex> vec(0..4) = A.Vector.new(0..4)
vec([0, 1, 2, 3, 4])
Variable lists or dynamic ranges cannot be passed:
vec(my_list) # invalid
vec(1..n) # invalid
Explanation
The vec/1
macro generates the AST at compile time instead of building the vector
at runtime. This can speedup the instanciation of vectors of known size.