Erlang / Erlang Basics Interview questions
What are lists in Erlang?
A list is a variable-length, ordered sequence written in square brackets, such as
[1, 2, 3] or [apple, banana]. Internally it's a singly linked chain of cons cells
— each cell holds a head element and a pointer to the rest of the list, ending in the empty list
[].
That linked structure is why prepending is cheap and appending to the end is not:
[Head | Tail] = [1, 2, 3], % Head = 1, Tail = [2, 3] New = [0 | [1, 2, 3]]. % O(1) prepend -> [0,1,2,3]
Because lists have no fixed length, they're the natural fit for sequences of unknown or varying size, while tuples suit fixed-shape data. Most list processing in Erlang is written recursively, walking the head/tail structure one element at a time, or via list comprehensions.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
