niiyz
5/12/2015 - 12:09 PM

Erlang リスト 2015.05.12

Erlang リスト 2015.05.12

45> List = [1,2,3,4,5].
[1,2,3,4,5]
46> [H|T] = List.
[1,2,3,4,5]
47> H.
1
48> T.
[2,3,4,5]
49> List2 = [0|List].
[0,1,2,3,4,5]
50> lists:reverse([1,2,3,4]).
[4,3,2,1]
51> [1,2,3,4]++[5,6,7,8].    
[1,2,3,4,5,6,7,8]
52> lists:append([1,2,3,4],[5,6,7,8]).
[1,2,3,4,5,6,7,8]
53> lists:append([[1,2], [3,4],[5,6],[7,8]]).
[1,2,3,4,5,6,7,8]
54> lists:last([1,2,3,hello,4,5]).
5
55> length([1,2,3,4,5,6,7,8,9]).
9
56> hd([1,2,3,4,5]).
1
57> tl([geesties, guilies, beasties]).
[guilies,beasties]
58> is_list([hello, erlang]).
true
59> list_to_atom("Erlang").
'Erlang'
60> atom_to_list('Erlang').
"Erlang"
61> list_to_float("2.2017764e+0").
2.2017764
62> float_to_list(7.0).
"7.00000000000000000000e+00"
63> list_to_integer("123").
123
64> integer_to_list(77).
"77"
65> erlang:list_to_integer("3FF", 16).
1023
66> erlang:integer_to_List(1023, 16).
** exception error: undefined function erlang:integer_to_List/2
67> erlang:integer_to_list(1023, 16).
"3FF"
68> list_to_pid("<0.4.1>").
<0.4.1>
69> Pid = spawn(fun() -> receive X -> X end end).
<0.106.0>
70> pid_to_list(Pid).                            
"<0.106.0>"
71> list_to_tuple([share, ['Ericsson_B', 163]]).
{share,['Ericsson_B',163]}
72> tuple_to_list({share, {'Ericsson_B', 163}}).
[share,{'Ericsson_B',163}]
73>