1
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.

paiza.ioでelixirAdvent Calendar 2022

Day 22

paiza.ioでelixir その47

Last updated at Posted at 2022-11-07

概要

paiza.ioでelixirやってみた。
Tuple使ってみた。

サンプルコード

tuple = {1, :two, "three"}
elem(tuple, 0)
|> IO.inspect
tuple_size({})
|> IO.puts
tuple = {:ok, :example}
Tuple.insert_at(tuple, 1, 55)
|> IO.inspect
tuple = {:foo, :bar}
Tuple.append(tuple, :baz)
|> IO.inspect
tuple = {:foo, :bar, :baz}
Tuple.delete_at(tuple, 2)
|> IO.inspect
Tuple.duplicate(:hello, 3)
|> IO.inspect
tuple = {:foo, :bar, :baz}
Tuple.to_list(tuple)
|> IO.inspect
put_elem({1, 2, 3}, 2, 4)
|> IO.inspect
tuple = {:ok, 42, "hello"}
|> put_elem(2, "bonjour")
|> IO.inspect
tuple = {:ok, 42, "hello"}
is_tuple(tuple)
|> IO.inspect







実行結果

1
0
{:ok, 55, :example}
{:foo, :bar, :baz}
{:foo, :bar}
{:hello, :hello, :hello}
[:foo, :bar, :baz]
{1, 2, 4}
{:ok, 42, "bonjour"}
true

成果物

以上。

1
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
1
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?