Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

This list shows some idioms having at least : 1 Elixir implementation with some empty fields.

You may click on a missing field and fill the gap.

Demo
URL
Doc
URL
# 222 Find the first index of an element ... Ø i = Enum.find_index(items, & &1 == x)
# 224 Add element to the beginning of the... Ø Ø items2 = [x | items]
# 41 Reverse a string Ø t = String.reverse(s)
# 26 Create a 2-dimensional array Ø x = for _ <- 1..m, do: for _ <- 1..n, do...
# 44 Insert element in list Ø List.insert_at(s, i, x)
# 14 Pick uniformly a random floating po... Ø a + :rand.uniform() * (b-a)
# 14 Pick uniformly a random floating po... Ø defmodule MyRandomPicker do def pick(a...
# 87 Stop program Ø System.halt()
# 48 Multi-line string literal Ø Ø s = "Spanning string works"
# 48 Multi-line string literal Ø s = """ multiline heredoc """
# 48 Multi-line string literal Ø s = ~S""" This will print multiline and ...
# 142 Hexadecimal digits of an integer Ø s = Integer.to_string(x, 16)
# 266 Repeated string Ø s = String.duplicate(v, n)
# 65 Format decimal number Ø s = "#{Float.round(x * 100, 1)}%"
# 91 Load JSON file into object Ø Ø defmodule JsonTest do def get_json(fil...
# 4 Set Cell Value Ø Ø @spec square(integer) :: integer def squ...
# 122 Declare an enumeration Ø Ø @suits %{ "SPADES" => 1, "HEARTS" =>...
# 28 Sort by a property Ø Enum.sort_by(items, &(&1.p))
# 137 Check if string contains only digit... Ø Ø b = Regex.match?(~r{\A\d*\z}, s)
# 94 Print the type of a variable Ø Ø [{_, type} | _] = IEx.Info.info(x) type
# 47 Extract string suffix t = String.slice(s, -5, 5)
# 47 Extract string suffix Ø <<_ :: binary-5>> <> t = s
# 64 Big integer : value 3 power 247 Ø Ø x = :math.pow(3, 247)
# 161 Multiply all the elements of a list Ø elements = Enum.map(elements, &(&1 * c))
# 80 Truncate floating point number to i... Ø y = trunc(x)
# 93 Pass a runnable procedure as parame... Ø Ø def control(f) do f() end
# 31 Recursive factorial (simple) Ø Ø defmodule Factorial do def f(0), do: 1...
# 244 Print a map Ø IO.inspect m
# 83 Regex with character repetition Ø r = Regex.compile!("htt+p")