3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Elixir: Map の使い方

Posted at

プログラム

map01.exs
# ------------------------------------------------------------------
#
#	map01.exs
#
#						Mar/04/2024
# ------------------------------------------------------------------
IO.puts :stderr,"*** 開始 ***"
#
dict_aa = %{
	t2381: %{name: "名古屋", population: 36952, date_mod: "1910-9-27"},
	t2382: %{name: "豊橋", population: 43951, date_mod: "1910-7-21"},
	t2383: %{name: "岡崎", population: 76352, date_mod: "1910-6-12"},
	t2384: %{name: "一宮", population: 28752, date_mod: "1910-1-17"},
	t2385: %{name: "蒲郡", population: 56251, date_mod: "1910-5-9"},
	t2386: %{name: "常滑", population: 16453, date_mod: "1910-9-16"},
	t2387: %{name: "大府", population: 81957, date_mod: "1910-8-5"},
	t2388: %{name: "瀬戸", population: 92947, date_mod: "1910-10-20"},
	t2389: %{name: "犬山", population: 34918, date_mod: "1910-7-11"}
}
#
ll = Map.keys dict_aa
#
Enum.each(ll, fn(s) ->
	str_out =  to_string(s) <> "\t" <>  dict_aa[s].name  <> "\t" <> Integer.to_string(dict_aa[s].population) <> "\t" <> dict_aa[s].date_mod
	IO.puts(str_out)
	end)
IO.puts :stderr,"*** 終了 ***"
# ------------------------------------------------------------------

実行結果

$ elixir map01.exs 
*** 開始 ***
t2381	名古屋	36952	1910-9-27
t2382	豊橋	43951	1910-7-21
t2383	岡崎	76352	1910-6-12
t2384	一宮	28752	1910-1-17
t2385	蒲郡	56251	1910-5-9
t2386	常滑	16453	1910-9-16
t2387	大府	81957	1910-8-5
t2388	瀬戸	92947	1910-10-20
t2389	犬山	34918	1910-7-11
*** 終了 ***

確認したバージョン

$ elixir -v
Erlang/OTP 25 [erts-13.1.5] [source] [64-bit] [smp:16:12] [ds:16:12:10] [async-threads:1] [jit:ns]

Elixir 1.14.0 (compiled with Erlang/OTP 24)
3
0
2

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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?