The Full Wiki

More info on Erlang Programming/Expressions

Erlang Programming/Expressions: Wikis

Advertisements

Note: Many of our articles have direct quotes from sources you can cite, within the Wikipedia article! This article doesn't yet, but we're working on it! See more info or our list of citable articles.

Wikibooks

Up to date as of January 23, 2010

From Wikibooks, the open-content textbooks collection

< Erlang Programming

Expressions

Erlang statements look a little like sentences. One statement a series of comma separated expressions ending with a period. Erlang expressions can either be ignored, stored, or returned depending on their position and structure in a statement.

4+3, H=6-2, lists:reverse([3,4,5]).
  [5,4,3]

In this Erlang example the expression: 4+3 is computed, the expression H=6-2 is computed, and the reverse of the list [3,4,5] is computed and returned. The results of 4+3 are ignored and the pattern 4 is matched to the variable H. For ever after H will have the unchangeable value 4. "lists" is the name of a standard module (library) that provides list utility functions.

Problems:

1) Write an expression that matches the pattern H2 to the reverse of the list [{1,2},{2,1}].

2) Write an expression that matches the pattern H3 to the length of the list [{1,2},{2,1}].

3) Write an expression that matches the pattern H4 to the length of the flattened version of the list [{1,2},{2,1}].


Advertisements






Got something to say? Make a comment.
Your name
Your email address
Message