<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Valkertown Blog - Latest Comments in Writting Circular Lists in Erlang</title><link>http://valkertownblog.disqus.com/</link><description>Sometimes stuff about electronics, others about technology and software</description><atom:link href="https://valkertownblog.disqus.com/writting_circular_lists_in_erlang/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Fri, 27 Mar 2009 17:45:21 -0000</lastBuildDate><item><title>Re: Writting Circular Lists in Erlang</title><link>http://blog.valkertown.org/2009/03/writting_circular_lists_in_erlang/#comment-7573404</link><description>&lt;p&gt;Thanks, I'll give it a try and do a benchmark to see if It's better to&lt;br&gt;the other solution in the above comments.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">deepspawn</dc:creator><pubDate>Fri, 27 Mar 2009 17:45:21 -0000</pubDate></item><item><title>Re: Writting Circular Lists in Erlang</title><link>http://blog.valkertown.org/2009/03/writting_circular_lists_in_erlang/#comment-7573160</link><description>&lt;p&gt;keep two lists {A, B} one in normal order the other reversed&lt;br&gt;To move forward do this&lt;/p&gt;&lt;p&gt;forward({[H|T],B}) -&amp;gt; {T, [H|B]};&lt;br&gt;forward({[], B}) -&amp;gt; forward({reverse(B),[]})&lt;/p&gt;&lt;p&gt;bawards is the opposite&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">nonme</dc:creator><pubDate>Fri, 27 Mar 2009 17:33:04 -0000</pubDate></item><item><title>Re: Writting Circular Lists in Erlang</title><link>http://blog.valkertown.org/2009/03/writting_circular_lists_in_erlang/#comment-7420870</link><description>&lt;p&gt;yeah ++ is less efficient. [Push | drop_last(List)] would be better. That's what I get for coding when I'm tired. but the basic concept is the same.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">zaphar</dc:creator><pubDate>Sun, 22 Mar 2009 17:53:49 -0000</pubDate></item><item><title>Re: Writting Circular Lists in Erlang</title><link>http://blog.valkertown.org/2009/03/writting_circular_lists_in_erlang/#comment-7363124</link><description>&lt;p&gt;Nice, I'm just repeating what I have read so far but&lt;/p&gt;&lt;p&gt; [Push] ++ drop_last(List)&lt;/p&gt;&lt;p&gt;Wouldn't it be better written as:&lt;/p&gt;&lt;p&gt; [ Push | drop_last(List)]&lt;/p&gt;&lt;p&gt;Anyway, ++ is discouraged since it makes a copy of the left operator and with long lists it would be highly inefficient, in this case it wouldn't be much of a problem but I still like more how the second one looks.&lt;/p&gt;&lt;p&gt;Thank you a lot for this idea, I'm guessing it's probably the best way to write it on erlang.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">deepspawn</dc:creator><pubDate>Thu, 19 Mar 2009 21:24:26 -0000</pubDate></item><item><title>Re: Writting Circular Lists in Erlang</title><link>http://blog.valkertown.org/2009/03/writting_circular_lists_in_erlang/#comment-7327546</link><description>&lt;p&gt;The key is to process the list in one pass. So if I read your intent above correctly then the following should work:&lt;/p&gt;&lt;p&gt;%% append the Push element to the beginning of the list while dropping the last element&lt;br&gt;circular(List, Push) -&amp;gt;&lt;br&gt;    [Push] ++ drop_last(List).&lt;/p&gt;&lt;p&gt;%% drop the last element from the list&lt;br&gt;drop_last([_]) -&amp;gt;&lt;br&gt;    [];&lt;br&gt;drop_last([H|T]) -&amp;gt;&lt;br&gt;    [H | drop_last(T)].&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">zaphar</dc:creator><pubDate>Wed, 18 Mar 2009 18:07:56 -0000</pubDate></item></channel></rss>