-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from hrzndhrn/issue/8
Comprehensions fix
- Loading branch information
Showing
10 changed files
with
162 additions
and
12 deletions.
There are no files selected for viewing
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 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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
defmodule Elixir.Comps do | ||
def one do | ||
for n <- [1, 2, 3] do | ||
:erlang.*(n, n) | ||
end | ||
end | ||
|
||
def two do | ||
for n <- [1, 2, 3], into: [], do: :erlang.*(n, n) | ||
end | ||
|
||
def three do | ||
for n <- [1, 2, 3], into: %{}, do: {n, :erlang.*(n, n)} | ||
end | ||
|
||
def four do | ||
for i <- [1, 2, 3], n <- [1, 2, 3], into: %{}, do: {i, n} | ||
end | ||
|
||
def five do | ||
for <<(<<x>> <- "abcabc")>>, uniq: true, into: "", do: <<:erlang.-(x, 32)>> | ||
end | ||
|
||
def six do | ||
for <<(<<x>> <- "AbCabCABc")>>, | ||
:erlang.andalso( | ||
:erlang.is_integer(x), | ||
:erlang.andalso( | ||
:erlang.>=( | ||
x, | ||
97 | ||
), | ||
:erlang."=<"( | ||
x, | ||
122 | ||
) | ||
) | ||
), | ||
reduce: %{}, | ||
do: (acc -> Map.update(acc, <<x>>, 1, fn x1 -> :erlang.+(x1, 1) end)) | ||
end | ||
|
||
def users(users) do | ||
for {type, name} when :erlang."/="(type, :guest) <- users do | ||
String.upcase(name) | ||
end | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
defmodule Elixir.Comps do | ||
def one do | ||
for n <- [1, 2, 3], into: [], do: :erlang.*(n, n) | ||
end | ||
|
||
def two do | ||
for n <- [1, 2, 3], into: [], do: :erlang.*(n, n) | ||
end | ||
|
||
def three do | ||
for n <- [1, 2, 3], into: %{}, do: {n, :erlang.*(n, n)} | ||
end | ||
|
||
def four do | ||
for i <- [1, 2, 3], n <- [1, 2, 3], into: %{}, do: {i, n} | ||
end | ||
|
||
def five do | ||
for <<(<<x>> <- "abcabc")>>, uniq: true, into: "", do: <<:erlang.-(x, 32)>> | ||
end | ||
|
||
def six do | ||
for <<(<<x>> <- "AbCabCABc")>>, | ||
:erlang.andalso( | ||
:erlang.is_integer(x), | ||
:erlang.andalso(:erlang.>=(x, 97), :erlang."=<"(x, 122)) | ||
), | ||
reduce: %{}, | ||
do: (acc -> Map.update(acc, <<x>>, 1, fn x1 -> :erlang.+(x1, 1) end)) | ||
end | ||
|
||
def users(users) do | ||
for {type, name} when :erlang."/="(type, :guest) <- users, into: [], do: String.upcase(name) | ||
end | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
defmodule Comps do | ||
def one do | ||
for n <- [1, 2, 3], do: n * n | ||
end | ||
|
||
def two do | ||
for n <- [1, 2, 3], into: [], do: n * n | ||
end | ||
|
||
def three do | ||
for n <- [1, 2, 3], into: %{}, do: {n, n * n} | ||
end | ||
|
||
def four do | ||
for i <- [1, 2, 3], | ||
n <- [1, 2, 3], | ||
into: %{}, | ||
do: {i, n} | ||
end | ||
|
||
def five do | ||
for <<x <- "abcabc">>, uniq: true, into: "", do: <<x - 32>> | ||
end | ||
|
||
def six do | ||
for <<x <- "AbCabCABc">>, x in ?a..?z, reduce: %{} do | ||
acc -> Map.update(acc, <<x>>, 1, &(&1 + 1)) | ||
end | ||
end | ||
|
||
def users(users) do | ||
for {type, name} when type != :guest <- users do | ||
String.upcase(name) | ||
end | ||
end | ||
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