Skip to content

Instantly share code, notes, and snippets.

@ferd
Created August 8, 2013 17:12
Show Gist options
  • Select an option

  • Save ferd/6186605 to your computer and use it in GitHub Desktop.

Select an option

Save ferd/6186605 to your computer and use it in GitHub Desktop.
$ erl
Erlang R16B (erts-5.10.1) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Eshell V5.10.1 (abort with ^G)
1> F = fun(F,_State) -> receive Bin -> F(F,Bin) end.
* 1: syntax error before: '.'
1> F = fun(F,_State) -> receive Bin -> F(F,Bin) end end.
#Fun<erl_eval.12.17052888>
2> Pid = spawn(fun() -> F(F,0) end).
<0.41.0>
3> Pid ! <<0:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
4> Pid ! <<0:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
5> Pid ! <<0:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
6> Pid ! <<0:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
7> length(element(2,process_info(Pid, binary))).
2
8> Pid ! <<1:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
9> Pid ! <<1:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
10> Pid ! <<1:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
11> Pid ! <<1:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
12> Pid ! <<1:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
13> length(element(2,process_info(Pid, binary))).
3
14> length(element(2,process_info(Pid, binary))).
3
15> Pid ! <<1:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
16> Pid ! <<1:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
17> Pid ! <<1:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
18> Pid ! <<1:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
19> Pid ! <<1:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
20> Pid ! <<1:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
21> length(element(2,process_info(Pid, binary))).
3
22> Pid ! <<3:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
23> Pid ! <<4:(120*8)>>.
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>
24> length(element(2,process_info(Pid, binary))).
1
25> [Pid ! <<N:(120*8)>> || N <- lists:seq(1,1000)].
[<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,...>>,
<<0,0,0,0,0,...>>,
<<0,0,0,0,...>>,
<<0,0,0,...>>,
<<0,0,...>>,
<<0,...>>,
<<...>>|...]
26> length(element(2,process_info(Pid, binary))).
129
27> length(element(2,process_info(Pid, binary))).
129
28> [Pid ! <<N:(120*8)>> || N <- lists:seq(1,1000)].
[<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,...>>,
<<0,0,0,0,0,...>>,
<<0,0,0,0,...>>,
<<0,0,0,...>>,
<<0,0,...>>,
<<0,...>>,
<<...>>|...]
29> length(element(2,process_info(Pid, binary))).
17
30> [Pid ! <<N:(120*8)>> || N <- lists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...>>,
<<0,0,0,0,...>>,
<<0,0,0,...>>,
<<0,0,...>>,
<<0,...>>,
<<...>>|...]
33> length(element(2,process_info(Pid, binary))).
113
34> length(element(2,process_info(Pid, binary))).
113
35> [Pid ! <<N:(120*8)>> || N <- lists:seq(1,10000)].
[<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,0,...>>,
<<0,0,0,0,0,0,...>>,
<<0,0,0,0,0,...>>,
<<0,0,0,0,...>>,
<<0,0,0,...>>,
<<0,0,...>>,
<<0,...>>,
<<...>>|...]
36> length(element(2,process_info(Pid, binary))).
57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment