Literate Programming

Stephen Han kruegger@REDACTED
Sat Mar 4 00:16:52 CET 2006


Hi...

I briefly looked at the wiki pedia insertion sort algorithm (honestly, it
was pseudo code :-P ) and I think this code also works, too.

Only difference is that I compare value from the beginning not from the end
in the inner loop.

-module(is).
-export([insert_sort/1]).

insert(Value, [H|T]) when Value >= H -> [H|insert(Value, T)];
insert(Value, T) -> [Value|T].

insert_sort(A) -> insert_sort(A, []).
insert_sort([], Acc) -> Acc;
insert_sort([Value|T], Acc) -> insert_sort(T, insert(Value, Acc)).

regards,


On 3/3/06, chandru <chandrashekhar.mullaparthi@REDACTED> wrote:
>
> On 03/03/06, Peter Marks <peter.c.marks@REDACTED> wrote:
> >
> > This article at LTU talks about a new Literate Programming (Knuth)
> website
> >
> > http://lambda-the-ultimate.org/node/1336
> >
> > I went there and they have a category for Erlang, but no programs yet!
> >
>
> There is one now. I've added an implementation of insertion sort. But
> I created a subcategory in the process instead of adding an article.
> If anyone knows how to fix it, please do.
>
> cheers
> Chandru
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20060303/e0681019/attachment.htm>


More information about the erlang-questions mailing list