Erlang (programming language)/Tutorials/Math: Difference between revisions

From Citizendium
Jump to navigation Jump to search
imported>Eric Evers
imported>Eric Evers
Line 10: Line 10:


  lists:map(Sqrt,[1,2,3,4]).
  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]
   [1.00000,1.41421,1.73205,2.00000]


  math:sin(3.1415/2).
  math:sin(3.1415/2).
   1.000000
   1.000000

Revision as of 14:25, 9 July 2008

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