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 Aula1 do | |
| @moduledoc """ | |
| Documentation for Aula1. | |
| """ | |
| @doc """ | |
| Hello world. | |
| ## Examples |
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 Kata do | |
| def fizz(x) when rem(x,3)==0, do: :fizz | |
| def fizz(x), do: x | |
| def buzz(x) when rem(x,5)==0, do: :buzz | |
| def buzz(x), do: x | |
| 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
| def fizzbuzz_aux(:fizz,:buzz), do: :fizzbuzz | |
| def fizzbuzz_aux(:fizz,_), do: :fizz | |
| def fizzbuzz_aux(_,:buzz), do: :buzz | |
| def fizzbuzz_aux(x,_), do: x |
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 Kata do | |
| def fizz(x) when rem(x,3)==0, do: :fizz | |
| def fizz(x), do: x | |
| def buzz(x) when rem(x,5)==0, do: :buzz | |
| def buzz(x), do: x | |
| def fizzbuzz_aux(:fizz,:buzz), do: :fizzbuzz | |
| def fizzbuzz_aux(:fizz,_), do: :fizz | |
| def fizzbuzz_aux(_,:buzz), 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
| def fizzbuzz_aux(:fizz,:buzz), do: :fizzbuzz | |
| def fizzbuzz_aux(:fizz,_), do: :fizz | |
| def fizzbuzz_aux(_,:buzz), do: :buzz | |
| def fizzbuzz_aux(x,_), do: x |
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 PoesiaCompilada do | |
| def mexeu_com_uma(true), do: "Mexeu com todas!" | |
| def mexeu_com_uma(_), do: "Vamos nos empoderar mesmo assim!" | |
| def main() do | |
| entrada = IO.gets("Mexeu com uma? (S/N): ") | |
| IO.puts(mexeu_com_uma(String.upcase(entrada)=="S\n")) | |
| end | |
| 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 FizzbuzzTest do | |
| use ExUnit.Case | |
| doctest Fizzbuzz | |
| test "fizzbuzz de 1 é 1" do | |
| assert Fizzbuzz.calcula(1) == 1 | |
| end | |
| test "fizzbuzz de 2 é 2" do | |
| assert Fizzbuzz.calcula(2) == 2 | |
| 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 Fizzbuzz do | |
| def calcula(x) do | |
| x | |
| end | |
| 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 Funcoes do | |
| def fatorial(1), do: 1 | |
| def fatorial(x), do: x*fatorial(x-1) | |
| def fibonacci(x) when x<=2, do: 1 | |
| def fibonacci(x), do: fibonacci(x-2)+fibonacci(x-1) | |
| def fibo_fat(x), do: x |> fibonacci |> fatorial | |
| def identidade(x), do: x |
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 Jokenpo do | |
| def joga(x,x), do: :empate | |
| def joga(:pedra,:tesoura), do: :pedra | |
| def joga(:pedra,:papel), do: :papel | |
| def joga(:tesoura,:papel), do: :tesoura | |
| # def joga(x,y), do: joga(y,x) | |
| def joga(:tesoura,:pedra), do: :pedra | |
| def joga(:papel,:pedra), do: :papel | |
| def joga(:papel,:tesoura), do: :tesoura | |
| end |