<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: 使用帮助？</title>
	<atom:link href="http://erlang-china.org/help/feed" rel="self" type="application/rss+xml" />
	<link>http://erlang-china.org</link>
	<description>erlang 中文社区</description>
	<lastBuildDate>Tue, 03 Jan 2012 15:49:56 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
	<item>
		<title>By: Aneisha</title>
		<link>http://erlang-china.org/help/comment-page-1#comment-22746</link>
		<dc:creator>Aneisha</dc:creator>
		<pubDate>Wed, 13 Apr 2011 00:37:22 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/help/#comment-22746</guid>
		<description>With the bases loaded you struck us out with that aswner!</description>
		<content:encoded><![CDATA[<p>With the bases loaded you struck us out with that aswner!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: unqiang</title>
		<link>http://erlang-china.org/help/comment-page-1#comment-21897</link>
		<dc:creator>unqiang</dc:creator>
		<pubDate>Fri, 11 Mar 2011 13:39:18 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/help/#comment-21897</guid>
		<description>一个有关抓取网页及2级网页URL的问题



-module(test).
-compile(export_all).
-import(lists,[reverse/1,reverse/2,map/2]).

 nano_get_url() -&gt;
	   nano_get_url(&quot;www.erlang.org&quot;).

 nano_get_url(Host) -&gt;
	 {ok,Socket} = gen_tcp:connect(Host, 80, [binary,{packet,0}]),
	 ok = gen_tcp:send(Socket,&quot;GET / HTTP/1.0\r\n\r\n&quot;),
	 receive_data(Socket,[]).

 receive_data(Socket,SoFar) -&gt;
	 receive
		 {tcp,Socket,Bin} -&gt;
			            receive_data(Socket,[Bin&#124;SoFar]);
		 {tcp_closed,Socket} -&gt; 
			     list_to_binary(lists:reverse(SoFar))
	 end.

urls2htmlFile(Urls,File) -&gt;
      file:write_file(File,urls2html(Urls)).

bin2urls(Bin) -&gt; gather_urls(binary_to_list(Bin),[]).

urls2html(Urls) -&gt; [h1(&quot;Urls&quot;),make_list(Urls)].

h1(Title) -&gt; [&quot;&quot;,Title,&quot;\n&quot;].

make_list(L) -&gt;
 [&quot;\n&quot;,
   map(fun(I) -&gt; [&quot;&quot;,I,&quot;\n&quot;] end, L),
   &quot;\n&quot;].

 gather_urls(&quot;&lt;a&gt;
  {Url,T1}=collect_url_body(T,reverse(&quot;&lt;a&gt; 
      gather_urls(T,L);
 gather_urls([],L) -&gt; 
   L.

collect_url_body(&quot;&lt;/a&gt;&quot; ++ T,L) -&gt; {reverse(L,&quot;&lt;/a&gt;&quot;),T};
collect_url_body([H&#124;T],L)       -&gt; collect_url_body(T,[H&#124;L]);
collect_url_body([],_)          -&gt; {[],[]}.
从哪儿加函数？</description>
		<content:encoded><![CDATA[<p>一个有关抓取网页及2级网页URL的问题</p>
<p>-module(test).<br />
-compile(export_all).<br />
-import(lists,[reverse/1,reverse/2,map/2]).</p>
<p> nano_get_url() -&gt;<br />
	   nano_get_url(&#8220;www.erlang.org&#8221;).</p>
<p> nano_get_url(Host) -&gt;<br />
	 {ok,Socket} = gen_tcp:connect(Host, 80, [binary,{packet,0}]),<br />
	 ok = gen_tcp:send(Socket,&#8221;GET / HTTP/1.0\r\n\r\n&#8221;),<br />
	 receive_data(Socket,[]).</p>
<p> receive_data(Socket,SoFar) -&gt;<br />
	 receive<br />
		 {tcp,Socket,Bin} -&gt;<br />
			            receive_data(Socket,[Bin|SoFar]);<br />
		 {tcp_closed,Socket} -&gt;<br />
			     list_to_binary(lists:reverse(SoFar))<br />
	 end.</p>
<p>urls2htmlFile(Urls,File) -&gt;<br />
      file:write_file(File,urls2html(Urls)).</p>
<p>bin2urls(Bin) -&gt; gather_urls(binary_to_list(Bin),[]).</p>
<p>urls2html(Urls) -&gt; [h1("Urls"),make_list(Urls)].</p>
<p>h1(Title) -&gt; ["",Title,"\n"].</p>
<p>make_list(L) -&gt;<br />
 ["\n",<br />
   map(fun(I) -&gt; ["",I,"\n"] end, L),<br />
   &#8220;\n&#8221;].</p>
<p> gather_urls(&#8220;<a><br />
  {Url,T1}=collect_url_body(T,reverse(&#8220;</a><a><br />
      gather_urls(T,L);<br />
 gather_urls([],L) -&gt;<br />
   L.</p>
<p>collect_url_body(&#8220;</a>&#8221; ++ T,L) -&gt; {reverse(L,&#8221;&#8220;),T};<br />
collect_url_body([H|T],L)       -&gt; collect_url_body(T,[H|L]);<br />
collect_url_body([],_)          -&gt; {[],[]}.<br />
从哪儿加函数？</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 棘手问题高手请帮忙解答</title>
		<link>http://erlang-china.org/help/comment-page-1#comment-9867</link>
		<dc:creator>棘手问题高手请帮忙解答</dc:creator>
		<pubDate>Fri, 02 Jan 2009 12:55:27 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/help/#comment-9867</guid>
		<description>The goal of this assignment is to make a distributed fault-tolerant application for a simple
computation of prime numbers. (Large prime numbers are user in security algorithms, if you
like to know a practical application of this algorithm).
A prime number is a number that is only dividable by 1 and itself, i.e. for N to be prime it
must hold that for all M between 2 and N-1 the erlang expression N rem M evaluates to
something unequal zero. The first few prime numbers are 1,2,3,5,7,11,13,…
Write a demonstrator for a fault-tolerant distributed application. A number of computers
should be connected in a network, say 1 to N.
It is known how they are positioned, i.e., 1 nest to 2, next to 3, … next to N.
On each computer you run the same program. This program computes the prime numbers, but
it skips numbers that other computers have already analyzed. Thus, if computer 1 starts to
compute whether 1 is a prime, then it informs the others, which decide to go on to the next
number (2, 3, 4, etc). In the end, all computers print a list of all prime numbers, but never
compute a prime number if one of the other computers already took that task.
As soon as a computer is disconnected from the network, or the Erlang node that it runs is
killed (simulating a crash), then the other computers continue working.
When a crashed computer is restarted (or the Erlang node restarted), the program joins the
pool and starts doing computations again.</description>
		<content:encoded><![CDATA[<p>The goal of this assignment is to make a distributed fault-tolerant application for a simple<br />
computation of prime numbers. (Large prime numbers are user in security algorithms, if you<br />
like to know a practical application of this algorithm).<br />
A prime number is a number that is only dividable by 1 and itself, i.e. for N to be prime it<br />
must hold that for all M between 2 and N-1 the erlang expression N rem M evaluates to<br />
something unequal zero. The first few prime numbers are 1,2,3,5,7,11,13,…<br />
Write a demonstrator for a fault-tolerant distributed application. A number of computers<br />
should be connected in a network, say 1 to N.<br />
It is known how they are positioned, i.e., 1 nest to 2, next to 3, … next to N.<br />
On each computer you run the same program. This program computes the prime numbers, but<br />
it skips numbers that other computers have already analyzed. Thus, if computer 1 starts to<br />
compute whether 1 is a prime, then it informs the others, which decide to go on to the next<br />
number (2, 3, 4, etc). In the end, all computers print a list of all prime numbers, but never<br />
compute a prime number if one of the other computers already took that task.<br />
As soon as a computer is disconnected from the network, or the Erlang node that it runs is<br />
killed (simulating a crash), then the other computers continue working.<br />
When a crashed computer is restarted (or the Erlang node restarted), the program joins the<br />
pool and starts doing computations again.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erlang-China &#187; Blog Archive &#187; 加了Erlang代码的语法加亮，show一下</title>
		<link>http://erlang-china.org/help/comment-page-1#comment-49</link>
		<dc:creator>Erlang-China &#187; Blog Archive &#187; 加了Erlang代码的语法加亮，show一下</dc:creator>
		<pubDate>Mon, 16 Apr 2007 13:15:36 +0000</pubDate>
		<guid isPermaLink="false">http://erlang-china.org/help/#comment-49</guid>
		<description>[...] 完整的示例可以参考这里。 [...]</description>
		<content:encoded><![CDATA[<p>[...] 完整的示例可以参考这里。 [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

