When To Use Elixir Range, Keyword Lists And MapSet — Tentamen Software Testing Blog

Image for post
Image for post
Elixir Range data type

TL;DR

Basic Vs. Higher Level Data Types

Range

Keyword Lists

Image for post
Image for post
Elixir Keyword List

Keyword list is a list of tuples, where the first tuple element is an atom. In Elixir it is used as an optional list of function parameters. Many Elixir libraries stick to that convention. We have two options to define a Keyword list and two options to use it as a function parameter. Remember that searching a list is O(n). Keyword lists are used over Maps as function parameters because they preserve element order, and one key could have multiply values.

MapSet

Image for post
Image for post
Elixir MapSet

MapSet is an enumerable set of unique values of any type.

Remember

  • The Range is a map with a small memory footprint
  • Range is enumerable
  • Keyword Lists is a list of special tuples
  • There is a Keyword module
  • Keywords are useful as optional function parameters
  • MapSet is a set of unique values.

Originally published at https://blog.tentamen.eu on October 2, 2020.

Written by

Founder of Tentamen, software testing agency.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store