Last active
November 28, 2017 11:36
-
-
Save tamanugi/d584e2c92d38c62616185112faf4974c to your computer and use it in GitHub Desktop.
ズンドコきよし with Elixir
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 Zundoko do | |
@zun "ズン" | |
@doko "ドコ" | |
@kiyoshi "キ ・ ヨ ・ シ!" | |
def run() do | |
gen_zundoko() | |
|> show_list | |
|> call | |
end | |
def call([@zun, @zun, @zun, @zun, @doko]) do | |
IO.puts @kiyoshi | |
end | |
def call([_head | tail] = list) when length(list) == 5 do | |
tail ++ gen_zundoko() | |
|> show_list | |
|> call | |
end | |
def call(list) do | |
list ++ gen_zundoko() | |
|> show_list | |
|> call | |
end | |
def show_list(list) do | |
IO.inspect list | |
list | |
end | |
def gen_zundoko do | |
zundoko = [@zun, @doko] |> Enum.random | |
[zundoko] | |
end | |
end | |
Zundoko.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment