The Full Wiki

More info on Erlang Programming/Using lists

Erlang Programming/Using lists: 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

Contents

Using lists

foreach

3> lists:foreach( fun(X)->X*X end, [1,2,3]).
>
produces no output because the purpose of foreach is to generate side-effects. However, 

4> lists:foreach( fun(X)->io:format("~w ",[X]) end, [1,2,3,4]).
1 2 3 4

does work, because io:format() is a side effect function.

sequence of numbers

lists:seq(1,100) is like range(1,100) in python.

sort

lists:sort( A ) is what you think.


Advertisements






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