This file contains hidden or 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 Decode do | |
@moduledoc """ | |
Extracted from https://github.com/ewildgoose/elixir-float_pp | |
""" | |
use Bitwise | |
@float_bias 1022 | |
############################################################################ |
This file contains hidden or 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 SteveTrollsElixir.Private do | |
defmacro __using__(_) do | |
quote do | |
import unquote(__MODULE__) | |
@on_definition {unquote(__MODULE__), :on_priv_def} | |
end | |
end | |
defmacro private() do | |
quote do |
This file contains hidden or 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 Capturepipe do | |
@doc """ | |
A pipe-operator that extends the normal pipe | |
in one tiny way: | |
It allows the syntax of having a bare `&1` capture | |
to exist inside a datastructure as one of the pipe results. | |
This is useful to insert the pipe's results into a datastructure | |
such as a tuple. |
This file contains hidden or 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 Capturepipe do | |
@doc """ | |
A pipe-operator that extends the normal pipe | |
in one tiny way: | |
It allows the syntax of having a bare `&1` capture | |
to exist inside a datastructure as one of the pipe results. | |
This is useful to insert the pipe's results into a datastructure | |
such as a tuple. |
This file contains hidden or 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 hidden or 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
{:beam_file, Addition, | |
[ | |
{:__info__, 1, 2}, | |
{:"__type_check_spec_for_add/2__", 0, 18}, | |
{:add, 2, 8}, | |
{:baseline_add, 2, 16}, | |
{:module_info, 0, 20}, | |
{:module_info, 1, 22} | |
], [vsn: [337339698024769425821845159222917769638]], | |
[ |
This file contains hidden or 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 Example do | |
use OverrideExample1 | |
use OverrideExample2 | |
@a 1 | |
@b 2 | |
end | |
# Prints at compile-time: | |
# | |
# yaay: {:a, [line: 4], [1]} | |
# wooh: {:a, [line: 4, context: OverrideExample2], [1]} |
This file contains hidden or 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
:- use_module(library(pairs)). | |
:- use_module(library(reif)). | |
not_in_list(K, L) :- | |
if_((L = []), | |
true, | |
([X | More] = L, | |
dif(K, X), | |
not_in_list(K, More))). |
This file contains hidden or 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
*> Compile using GNU Cobol, e.g.: `cobc -x gcd_maxmin.cob` | |
IDENTIFICATION DIVISION. | |
PROGRAM-ID. gcd-maxmin. | |
ENVIRONMENT DIVISION. | |
DATA DIVISION. | |
WORKING-STORAGE SECTION. | |
01 NUMS. | |
05 NUMS-ELEMS PIC 9(9) | |
OCCURS 0 TO 9999 TIMES DEPENDING ON NUMS-LEN. | |
77 NUMS-IDX PIC 9(9) COMP. |
This file contains hidden or 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
#! /usr/bin/env elixir | |
# Install required deps | |
Mix.install([:jason]) | |
# The pretty printing module | |
defmodule JsonPrettyPrinter do | |
def get_stdin_data do | |
# Fetch data from STDIN and decode JSON | |
:stdio |