Map [1]
Operation | Time Complexity |
---|---|
Access | O(log n) |
Search | O(log n) |
Insertion | O(n) for <= 32 elements, O(log n) for > 32 elements [2] |
Deletion | O(n) for <= 32 elements, O(log n) for > 32 elements |
defmodule MyMacro do | |
defmacro create_some_function_by_number(name, num, do: block) do | |
params = | |
for n <- 1..num do | |
{"id#{n}", Macro.var(:"id#{n}", nil)} | |
end | |
# We can't call Macro.escape because it is for escaping values. | |
# In this case, we have a mixture of values "id#{n}" and | |
# expressions "Macro.var(...)", so we build the map AST by hand. |