LoginSignup
13
0

More than 1 year has passed since last update.

簡単Elixirシリーズ ~ 整数nが与えられるので 1行にn回"hello"と出力してください。~

Last updated at Posted at 2022-12-15

簡単Elixirシリーズ

~ 整数nが与えられるので 1行にn回"hello"と出力してください。 ~

この記事は「Elixir Advent Calendar 2022」7日目の記事です
東京にいるけどfukuokaexのYOSUKEです。

簡単 Elixirシリーズでは小ネタをサクッと書いていこう。というコンセプトで作っていきます。

今回は、Twitter眺めてたら以下のツイート発見し、あ、 この小ネタやってみよ。という小ネタ(そう、この記事はサクッとがコンセプトW)

ということで早速書いてみた

iex()> num = &(1..&1)
iex()> hello = &Enum.map(num.(&1), fn _ -> "hello" end) |> Enum.join(" ")
iex()> hello.(5)
"hello hello hello hello hello"

簡単ですね。

13
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
0