DEV Community

Discussion on: Which Data Structure Should I Use? An Elixir Cheat Sheet

Collapse
 
erikpischel profile image
Erik Pischel • Edited

"Tuples are ordered collections of values." So how is this different to lists?

Collapse
 
rubberduck profile image
Christopher McClellan

Essentially, they’re not different. Lists are actually just tupples of tupples.

[1,2,3] is really {1, { 2, {3, nil}}}

Most, of not all FP languages represent lists this way, usually with a bit of syntactic sugar. This all comes from λ calculus, which is worthwhile to learn if you’re into FP.