This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Elixir 1.14.0-dev | |
Erlang 24.3 | |
Benchmark suite executing with the following configuration: | |
warmup: 2 s | |
time: 5 s | |
memory time: 5 s | |
reduction time: 0 ns | |
parallel: 1 | |
inputs: keyword_100_desc, keyword_1000_desc, keyword_10000_desc, keyword_100000_desc, map_100_desc, map_1000_desc, map_10000_desc, map_100000_desc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Operating System: Linux | |
... | |
Elixir 1.14.0-dev | |
Erlang 24.3 | |
... | |
Benchmark suite executing with the following configuration: | |
warmup: 2 s | |
time: 2 s | |
memory time: 2 s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Original idea taken from: https://unix.stackexchange.com/questions/556240/how-can-a-command-within-a-pipeline-abort-the-pipeline | |
exit_on_warning() { | |
sed '/atom ::: must be written between quotes, as in :"::", to avoid ambiguity/{q 2}' || kill "$BASHPID" | |
} | |
run() { | |
make docs_elixir | |
echo "Docs successfully generated!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Variadic do | |
# https://elixirforum.com/t/defining-an-anonymous-function-of-dynamic-arity-not-variadic/38228/7?u=eksperimental | |
def spread_combine(h, f, g) do | |
{:arity, f_arity} = Function.info(f, :arity) | |
{:arity, g_arity} = Function.info(g, :arity) | |
args = Macro.generate_arguments(f_arity + g_arity, __MODULE__) | |
{f_args, g_args} = Enum.split(args, f_arity) | |
fn_ast = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Variadic do | |
@moduledoc """ | |
Solution for https://elixirforum.com/t/defining-an-anonymous-function-of-dynamic-arity-not-variadic/38228 | |
""" | |
defmacro spread_combine(h, f, g) do | |
quote bind_quoted: [h: h, f: f, g: g, module: __CALLER__.module], | |
location: :keep do | |
{:arity, f_arity} = Function.info(f, :arity) | |
{:arity, g_arity} = Function.info(g, :arity) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Downloaded from: https://gist.github.com/eksperimental/55f1e207ab5878a668668546f57a3f90 | |
# | |
# Lists all the types that have the problem reported in | |
# https://github.com/elixir-lang/elixir/issues/10140 | |
# create an Elixir project, and save this file in lib/typespec_example.ex | |
# Start IEx with: iex -S mix | |
# then run: TypespecExample.types() | |
# and paste the output into the shell. | |
defmodule TypespecExample do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Collectable | |
elixir$ ag "defimpl\s+Collectable" -G ".ex$" | |
HashDict | |
lib/elixir/lib/hash_dict.ex | |
247:defimpl Collectable, for: HashDict do | |
IO.Stream | |
lib/elixir/lib/io/stream.ex | |
35: defimpl Collectable do | |
File.Stream |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EditorConfig is awesome: http://EditorConfig.org | |
# .editorconfig for Elixir projects | |
# https://git.io/elixir-editorconfig | |
# top-most EditorConfig file | |
root = true | |
[*] | |
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://elixirforum.com/t/newbie-needs-help-parsing-a-file/1762 | |
defmodule RecordFile do | |
def read(file) do | |
{:ok, data} = File.read(file) | |
data | |
|> String.split("\n") | |
|> filter | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Guard.Helpers do | |
@moduledoc """ | |
Tools for creating custom guards. | |
""" | |
@doc """ | |
Creates a macro that's aware of its presence in a guard. | |
Taken from https://github.com/elixir-lang/elixir/blob/df8b216357e023e4ef078be396fed6b873d6a938/lib/elixir/lib/kernel.ex#L1601-L1615, |
NewerOlder