Erlang (programming language)/Tutorials/Lists: Difference between revisions
imported>Eric Evers m (→Lists Module) |
imported>Eric Evers |
||
Line 2: | Line 2: | ||
=Lists Module= | =Lists Module= | ||
Lists provides list functions. There is a non-standard parallel version available called plists. | |||
==Filter== | |||
1> F1 = fun(Item) -> length(Item) > 1 end. | |||
#Fun<erl_eval.6.58606484> | |||
2> lists:filter(F1, [[1],[1,2],[1,2,3]]). | |||
[[1,2,3],[1,2]] | |||
==Map== | ==Map== |
Revision as of 12:34, 2 June 2008
The metadata subpage is missing. You can start it via filling in this form or by following the instructions that come up after clicking on the [show] link to the right. | |||
---|---|---|---|
|
Lists Module
Lists provides list functions. There is a non-standard parallel version available called plists.
Filter
1> F1 = fun(Item) -> length(Item) > 1 end. #Fun<erl_eval.6.58606484> 2> lists:filter(F1, [[1],[1,2],[1,2,3]]). [[1,2,3],[1,2]]
Map
6> Sqrt = fun(X) -> math:sqrt(X) end. #Fun<erl_eval.6.56006484>
7> lists:map(Sqrt,[1,2,3,4]). [1.00000,1.41421,1.73205,2.00000]
Sort
lists:sort([2,4,3,5]). [2,3,4,5]