本帖最后由 shijiang1130 于 2014-10-02 19:13 编辑 [code]-module(tracert). -export([run/0]). run() -> P5 = erlang:open_port({spawn, "tracert 8.8.8.8"}, [stderr_to_stdout, in, exit_status,stream, {line, 255}]), loop(P5). loop(P) -> receive {P,{exit_status,_}} -> io:format("Pid been killed, try restart ...~n"), run(); {P, Data} -> ...
by shijiang1130 - Erlang - 2016-05-17 17:51:36 阅读(600) 回复(2)
注意: 从erlang R17才可供使用。 8> maps:new(). #{} 9> F1 = #{a=>32424223,b=>444444444}. #{a => 32424223,b => 444444444} 10> F1. #{a => 32424223,b => 444444444}
[code]1> inets:start(). ok 2> yaws_soap_lib:call( "http://www.webservicex.net/WeatherForecast.asmx?WSDL", "GetWeatherByPlaceName", ["Boston"]).[/code]http://yaws.hyber.org/soap_intro.yaws
lists:usort/1[code]11> A=[1,1,22,3,33,22]. [1,1,22,3,33,22] 12> lists:usort(A). [1,3,22,33] 13> [/code]
本帖最后由 shijiang1130 于 2014-10-06 16:58 编辑 https://github.com/davisp/jiffy erlang解析json
[code]-module(calculate). -compile(export_all). t() -> statistics(runtime), statistics(wall_clock), timer:sleep(10000), {_, Time1} = statistics(runtime), {_, Time2} = statistics(wall_clock), U1 = Time1 * 1000, U2 = Time2 * 1000, io:format("Code time=~p (~p) microseconds~n", [U1,U2]).[/code]
The Eight Myths of erlang Performance Some truths seem to live on well beyond their best-before date, perhaps because "information" spreads more rapidly from person-to-person faster than a single release note that notes, for instance, that funs have become faster. Here we try to kill the old truths (or semi-truths) that have become myths. 2.1 Myth: Funs are slow Yes, funs used to be slow. Ver...
https://www.sics.se/~joe/talks/ll2_2002.pdf 1. Factorial -module(math). -export([fac/1]). fac(N) when N > 0 -> N * fac(N-1); fac(0) -> 1. > math:fac(25). 15511210043330985984000000