Erlang Learning Notes

Source: Internet
Author: User

  • Erlang is a functional programming language with immutable state
  • The variable of Erlang is a one-time assignment variable (single-assignment variable)
  • In Erlang, the obtained value of a variable is the result of a successful pattern matching operation, = is a pattern matching operator
  • In Erlang, atoms are used to represent constant values, atoms are global, start with lowercase letters, and can be placed in single quotes, and the value of an atom is itself.
  • Tuples are used to classify a number of fixed items into a single entity, enclosed in curly braces, which are automatically created when declared and destroyed when they are no longer in use.
  • For variables that are not interested, you can use _ as a placeholder, and the symbol _ is called an anonymous variable.
  • Lists are used to hold any number of elements, enclosed in brackets, the first element of the list is called the list header, and the remainder is called the list footer.
  • There is no string in Erlang, the string in Erlang is represented as a list of integers or a binary, and when the string is represented as a list of integers, each element in the list represents a Unicode code point. You can create such a list with string literals, which are a string of characters enclosed in double quotation marks. When the shell prints the value of a list, only if all the integers in the list represent printable characters characters print the string literal.
  • F () command to let the shell forget all existing bindings
  • Modules and functions are the basic units for building order and parallel programs, and the modules contain functions that can be run sequentially or in parallel
  • -module (module_name) is a module declaration, located in the first line of the file, module_name must be the same as the main file name that holds the module
  • Export ([FUNC_NAME/1]) is a declaration of exports, name/n this notation refers to a function with n parameters name,n is called the number of functions (arity), the export parameter is a list composed of name/n, Functions that are not exported can only be called within a module (equivalent to private methods)
  • Comma-separated function calls, data constructs, and parameters in the schema
  • Semicolon-delimited clauses, such as function definitions, and case,if,try...catch, and receive expressions
  • The period separates the function as a whole, and the expression in the shell
  • The data types used to represent functions in Erlang are called fun, and functions that manipulate other functions are called higher-order functions (Higher-order function).
  • Erlang does not have a separate Boolean type, but atomic true and false have special meanings that can be used to represent Boolean values, and there are four available Boolean expressions: not, and, or, XOR
  • From version r16b, Erlang source code files are assumed to be encoded with the UTF-8 character set
  • The number in Erlang is not an integer or a floating point, and a K-binary integer uses the k#digits notation.
  • Short-circuit evaluation: OrElse AndAlso
  • Types are used for type definitions, such as pre-defined type aliases:-type term ():: Any (). -type term ():: true | False. -type byte ():: 0..255. -type list ():: [Any ()].
  • Creating and destroying processes in Erlang is very fast, sending messages between processes is very fast, can have a large number of processes, the process does not share any memory, is completely independent, and the only way to interact is through message delivery

Erlang Learning Notes

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.