I’m new to Elixir and I’m trying to create a simple anonymous function that concatenates two lists of atoms.
Correctly, the code written is:
iex (1) >list_concat = fn[:a,:b], [:c,:d] -> [:a,:b,:c,:d] end
iex (2) >list_concat.([:1,:2],[:3,:4])
iex throws the following error
** (SyntaxError) iex:40: unexpected token: “:” (column 17, codepoint U+003A)
Anyone help to understand and unblock me?
An atom is a literal, a constant with name. An atom is to be enclosed in single quotes (’) if it does not begin with a lower-case letter or if it contains other characters than alphanumeric characters, underscore (_), or @.
Warning: this function creates atoms dynamically and atoms are not garbage-collected. Therefore, string should not be an untrusted value, such as input received from a socket or during a web request.