- Dynamic Dispatch
- Dynamic Method
- Ghost Methods
- Dynamic Proxies
- Blank Slate
- Kernel Method
- Flattening the Scope (aka Nested Lexical Scopes)
- Context Probe
- Class Eval (not really a 'spell' more just a demonstration of its usage)
- Class Macros
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 Day do | |
@spec count_valid() :: number() | |
def count_valid do | |
pwds = String.split(input(), "\n") | |
Enum.count(pwds, fn(ln) -> line_valid?(ln) end) | |
end | |
@spec line_valid?(string) :: boolean() | |
defp line_valid?(line) 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
defmodule Wordcount do | |
@moduledoc """ | |
Documentation for Wordcount. | |
""" | |
@spec count(String.t) :: map | |
def count(sentence) do | |
sentence | |
|> String.downcase | |
|> String.replace(~r/[,\.&:!@\$%\^]+/, "") |
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
# This prints out the nth member of the sequence | |
def fib(n) | |
last_two = [0,1] | |
3.upto(n) do | |
last_two = last_two[1], last_two.inject(:+) | |
end | |
puts last_two.last | |
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
if Version.compare(System.version(), "1.4.0") == :lt do | |
def enum_split_with(enum, fun), do: Enum.partition(enum, fun) | |
else | |
def enum_split_with(enum, fun), do: Enum.split_with(enum, fun) | |
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
iex(4)> Version.parse!("2.3.4") | |
#Version<2.3.4> | |
iex(5)> Version.parse!("0.09") | |
** (Version.InvalidVersionError) invalid version: "0.09" |
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
iex(9)> v = Version.parse!("1.0.0-alpha.3+20130417140000") | |
#Version<1.0.0-alpha.3+20130417140000> | |
iex(10)> v.build | |
"20130417140000" | |
iex(11)> v.pre | |
["alpha", 3] | |
iex(12)> v.patch |
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
iex(17)> {:ok, requirement} = Version.parse_requirement("== 2.0.1") | |
{:ok, #Version.Requirement<== 2.0.1>} |
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
iex> Version.match?("2.0.0", "> 1.0.0") | |
true | |
iex> Version.match?("2.0.0", "== 1.0.0") | |
false |
I hereby claim:
- I am supersimple on github.
- I am supersimple (https://keybase.io/supersimple) on keybase.
- I have a public key ASCtr8jm-HKtUdu96MUKexbw-UjojwK3mdljan-v1bcK6Ao
To claim this, I am signing this object: