Elixir BASIC Data structure

Source: Internet
Author: User
Some of the underlying data structures in elixir: integers, floating-point numbers, strings, atoms, lists, tuples
integers, floating-point numbers, strings similar to other languages
Atomic: A constant named value in Ruby similar to symbols in Erlang is defined with the beginning of the capital letter
iex> :hello:hello
iex> :hello == :worldfalse



列表:Elixir用方括号来表示一个列表,列表内元素的类型是随意的
iex(13)> [2,3,4]
[2, 3, 4]

++ --
iex(14)> [2,3,4] ++ [5,6,7]
[2, 3, 4, 5, 6, 7]
iex(15)> [2,3,4] -- [1,2]
[3, 4]

列表的头和尾
iex(21)> list = [1,2,3]
[1, 2, 3]
iex(22)> hd(list)
1
iex(23)> tl(list)
[2, 3]

元组:Elixir用花括号来表示元组
elem--取元组第几个
iex(26)> tuple = {:ok, "hello"}
{:ok, "hello"}
iex(27)> elem(tuple, 0)
:ok
iex(28)> elem(tuple, 1)
"hello"



 
 

Elixir BASIC Data structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.