- Ghostbin: não exige criação de conta e tem sintaxe Elixir. Exemplo. Permite dar nome ao arquivo, mas tem que ser em minúscula e sem terminação.
- Pastebin não tem sintaxe Elixir
- GitHubGist exige criação de conta
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
| # No arquivo de código | |
| defmodule CaixaEletronico do | |
| def saque(_,_), do: nil | |
| end | |
| # No arquivo de testes | |
| defmodule CaixaeletronicoTest do | |
| use ExUnit.Case | |
| doctest CaixaEletronico |
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 CaixaeletronicoTest do | |
| use ExUnit.Case | |
| doctest CaixaEletronico | |
| test "calcula as notas para 200 reais" do | |
| assert CaixaEletronico.saque(200,[100])==[{100,2}] | |
| end | |
| test "calcula as notas para 100 reais" do | |
| assert CaixaEletronico.saque(100,[100])==[{100,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
| defmodule CaixaEletronico do | |
| def saque(valor,[nota]), do: [{nota,div(valor,nota)}] | |
| def saque(valor,[nota1, nota2]) do | |
| [{nota1,div(valor,nota1)}, | |
| {nota2,div(rem(valor,nota1),nota2)}, | |
| ] | |
| end | |
| def saque(valor,[nota_cabeca|resto_lista_notas]) do | |
| :erro | |
| end |
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
| @lpc {[:p, :q, :r], %{:nao => 1, :e => 2, :ou => 2, :implica => 2}} | |
| test "A fórmula :p é bem formada" do | |
| assert formula_bem_formada?(:p, @lpc) | |
| end | |
| test "A fórmula :s NÃO é bem formada" do | |
| refute formula_bem_formada?(:s, @lpc) | |
| end |
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 Logic do | |
| @spec boolean ~> boolean :: boolean | |
| def x ~> y do | |
| not x or y | |
| end | |
| end | |
| # Modo de usar: | |
| # - Salvar como logic.ex | |
| # - Na mesma pasta, chamar |
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
| \newcommand{\AND}{\wedge} | |
| \newcommand{\OR}{\vee} | |
| \newcommand{\IMPLIES}{\rightarrow} | |
| \newcommand{\NOT}{\neg} | |
| \newcommand{\T}{{\cal T}\,} | |
| \newcommand{\F}{{\cal F}\,} |
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 LookAndSay do | |
| def lookandsay(numero) do | |
| numero | |
| |> Integer.digits() | |
| |> lookandsay_inicia() | |
| |> Integer.undigits() | |
| end | |
| defp lookandsay_inicia([cabeca | cauda]) do | |
| lookandsayauxaux(cabeca, cauda, 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
| defmodule Fizz do | |
| def fizz(x) when rem(x,3)==0 do | |
| "fizz" | |
| end | |
| def fizz(x) do | |
| x | |
| end | |
| def buzz(x) when rem(x,5)==0, do: "buzz" |
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
| fizz(numero: Inteiro) | |
| se numero mod 3 == 0 então | |
| "fizz" | |
| senão | |
| "{numero}" | |
| fim | |
| fim | |
| buzz(numero: Inteiro) | |
| se numero mod 5 == 0 então |