paiza.ioでelixir その231

# 概要
paiza.ioでelixirやってみた。
良いコードを見つけたので、やってみた。

# 参考にしたページ。

https://qiita.com/nori-channel/items/536a5a4ec867a9c383f3

# サンプルコード

```
Enum.__info__(:functions) 
|> Enum.each(fn({function, arity}) ->
    IO.puts "#{function}/#{arity}"
end)
|> IO.inspect
Enum.all?(["foo", "bar", "hello"], fn(s) -> 
    String.length(s) == 3 
end)
|> IO.inspect
Enum.all?(["foo", "bar", "hello"], fn(s) -> 
    String.length(s) > 1 
end)
|> IO.inspect
Enum.any?(["foo", "bar", "hello"], fn(s) -> 
    String.length(s) == 5 
end)
|> IO.inspect
Enum.chunk_every([1, 2, 3, 4, 5, 6], 2)
|> IO.inspect
Enum.chunk_by(["one", "two", "three", "four", "five"], fn(x) -> 
    String.length(x) 
end)
|> IO.inspect
Enum.chunk_by(["one", "two", "three", "four", "five", "six"], fn(x) -> 
    String.length(x) 
end)
|> IO.inspect
Enum.map_every([1, 2, 3, 4, 5, 6, 7, 8], 3, fn x -> 
    x + 1000 
end)
|> IO.inspect
Enum.each(["one", "two", "three"], fn(s) -> 
    IO.puts(s) 
end)
|> IO.inspect
Enum.map([0, 1, 2, 3], fn(x) -> 
    x - 1 
end)
|> IO.inspect
Enum.min([5, 3, 0, -1])
|> IO.inspect
Enum.min([], fn -> 
    :foo 
end)
|> IO.inspect
Enum.max([5, 3, 0, -1])
|> IO.inspect
Enum.max([], fn -> 
    :bar 
end)
|> IO.inspect
Enum.filter([1, 2, 3, 4], fn(x) -> 
    rem(x, 2) == 0 
end)
|> IO.inspect
Enum.reduce([1, 2, 3], 10, fn(x, acc) -> 
    x + acc 
end)
|> IO.inspect
Enum.reduce([1, 2, 3], fn(x, acc) -> 
    x + acc 
end)
|> IO.inspect
Enum.reduce(["a", "b", "c"], "1", fn(x, acc)-> 
    x <> acc 
end)
|> IO.inspect
Enum.sort([5, 6, 1, 3, -1, 4])
|> IO.inspect
Enum.sort([:foo, "bar", Enum, -1, 4])
|> IO.inspect
Enum.sort([%{:val => 4}, %{:val => 1}], fn(x, y) -> 
    x[:val] > y[:val] 
end)
|> IO.inspect
Enum.sort([%{:count => 4}, %{:count => 1}])
|> IO.inspect
Enum.sort([2, 3, 1], :desc)
|> IO.inspect
Enum.uniq([1, 2, 3, 2, 1, 1, 1, 1, 1])
|> IO.inspect
Enum.uniq_by([%{x: 1, y: 1}, %{x: 2, y: 1}, %{x: 3, y: 3}], fn coord -> 
    coord.y 
end)
|> IO.inspect
Enum.map([1, 2, 3], fn number -> 
    number + 3 
end)
|> IO.inspect
Enum.map([1, 2, 3], &(&1 + 3))
|> IO.inspect
plus_three = &(&1 + 3)
|> IO.inspect
Enum.map([1, 2, 3], plus_three)
|> IO.inspect
defmodule Adding do
   def plus_three(number), do: number + 3
end
|> IO.inspect
Enum.map([1, 2, 3], fn number -> 
    Adding.plus_three(number) 
end)
|> IO.inspect
Enum.map([1, 2, 3], &Adding.plus_three(&1))
|> IO.inspect
Enum.map([1, 2, 3], &Adding.plus_three/1)
|> IO.inspect







```

# 実行結果

```
all?/1
all?/2
any?/1
any?/2
at/2
at/3
chunk/2
chunk/3
chunk/4
chunk_by/2
chunk_every/2
chunk_every/3
chunk_every/4
chunk_while/4
concat/1
concat/2
count/1
count/2
count_until/2
count_until/3
dedup/1
dedup_by/2
drop/2
drop_every/2
drop_while/2
each/2
empty?/1
fetch/2
fetch!/2
filter/2
filter_map/3
find/2
find/3
find_index/2
find_value/2
find_value/3
flat_map/2
flat_map_reduce/3
frequencies/1
frequencies_by/2
group_by/2
group_by/3
intersperse/2
into/2
into/3
join/1
join/2
map/2
map_every/3
map_intersperse/3
map_join/2
map_join/3
map_reduce/3
max/1
max/2
max/3
max_by/2
max_by/3
max_by/4
member?/2
min/1
min/2
min/3
min_by/2
min_by/3
min_by/4
min_max/1
min_max/2
min_max_by/2
min_max_by/3
min_max_by/4
partition/2
product/1
random/1
reduce/2
reduce/3
reduce_while/3
reject/2
reverse/1
reverse/2
reverse_slice/3
scan/2
scan/3
shuffle/1
slice/2
slice/3
sort/1
sort/2
sort_by/2
sort_by/3
split/2
split_while/2
split_with/2
sum/1
take/2
take_every/2
take_random/2
take_while/2
to_list/1
uniq/1
uniq/2
uniq_by/2
unzip/1
with_index/1
with_index/2
zip/1
zip/2
zip_reduce/3
zip_reduce/4
zip_with/2
zip_with/3
:ok
false
true
true
[[1, 2], [3, 4], [5, 6]]
[["one", "two"], ["three"], ["four", "five"]]
[["one", "two"], ["three"], ["four", "five"], ["six"]]
[1001, 2, 3, 1004, 5, 6, 1007, 8]
one
two
three
:ok
[-1, 0, 1, 2]
-1
:foo
5
:bar
[2, 4]
16
6
"cba1"
[-1, 1, 3, 4, 5, 6]
[-1, 4, Enum, :foo, "bar"]
[%{val: 4}, %{val: 1}]
[%{count: 1}, %{count: 4}]
[3, 2, 1]
[1, 2, 3]
[%{x: 1, y: 1}, %{x: 3, y: 3}]
[4, 5, 6]
[4, 5, 6]
4
5
6
[4, 5, 6]
{:module, Adding,
 <<70, 79, 82, 49, 0, 0, 5, 28, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 0, 145,
   0, 0, 0, 15, 13, 69, 108, 105, 120, 105, 114, 46, 65, 100, 100, 105, 110,
   103, 8, 95, 95, 105, 110, 102, 111, 95, 95, ...>>, {:plus_three, 1}}
[4, 5, 6]
[4, 5, 6]
[4, 5, 6]
```

# 成果物

https://paiza.io/projects/fQWgPyVJp58UlPQS0beTPQ?language=elixir


以上。