Help us understand the problem. What is going on with this article?

Elixir言語で5の倍数と5のつく数字だけヒロミゴーする

More than 3 years have passed since last update.

経緯

完全に@kmagaiさんのGo言語で5の倍数と5のつく数字だけヒロミゴーするに乗っかりました。

Goではないですが、どんな言語でもヒロミゴーでエキゾチック・ジャパンなFizzBuzzして良いのでは???という思いです。

ルールは全く同じ。5がつく数字でExotic、5の倍数でJapan、両立したらExotic Japan。

コード

go.exs
defmodule ExoticJapan do
  def go!(num) when num > 0 do
    Enum.each 1..num, fn (i) ->
      IO.puts "#{i} " <> hiromi(exotic?(i), japan?(i))
    end
  end

  defp hiromi(true,   true), do: "Exotic Japan"
  defp hiromi(true,  false), do: "Exotic"
  defp hiromi(false,  true), do: "Japan"
  defp hiromi(false, false), do: ""

  defp exotic?(num), do: to_string(num) |> String.contains?("5")

  defp japan?(num), do: rem(num, 5) == 0
end

System.argv |> List.first |> String.to_integer |> ExoticJapan.go!
$ elixir go.exs 240000000

所感

hiromi/2が美しくない。もうちょっとどうにかならんかね。

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away