erlang array

array() :: record(array,size,max,default,elements).

 

foldl函数

   A1 = array:from_list([1,2,3,4,5,6,7,8,9,10]),
   array:foldl(fun(Index,Value,Acc) -> [Value|Acc] end,[],A1).

结果:[10,9,8,7,6,5,4,3,2,1]

 

from_orddict函数

  array:from_orddict([{1,1},{3,3}]).

结果:{array,4,10,undefined,
           {undefined,1,undefined,3,undefined,undefined,undefined,undefined,undefined,undefined}

   }

 

 

to_orddict与sparse_to_orddict

  to_orddict

  A1 = array:from_orddict([{1,1},{3,3}]),
    array:to_orddict(A1).

结果:[{0,undefined},{1,1},{2,undefined},{3,3}]

  sparse_to_orddict

  A1 = array:from_orddict([{1,1},{3,3}]),
  array:sparse_to_orddict(A1).

结果:[{1,1},{3,3}]

 

posted on 2014-08-27 15:18  Vinlan  阅读(260)  评论(0)    收藏  举报

导航