Erlang (programming language)/Tutorials/Math

From Citizendium
< Erlang (programming language)‎ | Tutorials
Revision as of 07:07, 8 August 2009 by imported>Tom Morris (Erlang programming language/Tutorials/Math moved to Erlang (programming language)/Tutorials/Math)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Math

2*math:asin(1).
 3.1415

math:sqrt(4).
 2
Sqrt = fun(X) -> math:sqrt(X) end.
 #Fun<erl_eval.6.56006484>
lists:map(Sqrt,[1,2,3,4]).
 [1.00000,1.41421,1.73205,2.00000]
lists:map(fun math:sqrt/1, [1,2,3,4]).
 [1.00000,1.41421,1.73205,2.00000]
math:sin(3.1415/2).
 1.000000