<div>Hi...</div>
<div> </div>
<div>I briefly looked at the wiki pedia insertion sort algorithm (honestly, it was pseudo code :-P ) and I think this code also works, too.</div>
<div> </div>
<div>Only difference is that I compare value from the beginning not from the end in the inner loop.</div>
<div> </div>
<div>-module(is).<br>-export([insert_sort/1]).</div>
<div> </div>
<div>insert(Value, [H|T]) when Value >= H -> [H|insert(Value, T)];<br>insert(Value, T) -> [Value|T].</div>
<div> </div>
<div>insert_sort(A) -> insert_sort(A, []).<br>insert_sort([], Acc) -> Acc;<br>insert_sort([Value|T], Acc) -> insert_sort(T, insert(Value, Acc)).</div>
<div><br>regards, </div>
<div><br> </div>
<div><span class="gmail_quote">On 3/3/06, <b class="gmail_sendername">chandru</b> <<a href="mailto:chandrashekhar.mullaparthi@gmail.com">chandrashekhar.mullaparthi@gmail.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On 03/03/06, Peter Marks <<a href="mailto:peter.c.marks@gmail.com">peter.c.marks@gmail.com</a>> wrote:
<br>><br>> This article at LTU talks about a new Literate Programming (Knuth) website<br>><br>> <a href="http://lambda-the-ultimate.org/node/1336">http://lambda-the-ultimate.org/node/1336</a><br>><br>> I went there and they have a category for Erlang, but no programs yet!
<br>><br><br>There is one now. I've added an implementation of insertion sort. But<br>I created a subcategory in the process instead of adding an article.<br>If anyone knows how to fix it, please do.<br><br>cheers<br>Chandru
<br></blockquote></div><br>