Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,16 @@
|
|||
-module( bubble_sort ).
|
||||
|
||||
-export( [list/1, task/0] ).
|
||||
|
||||
list( To_be_sorted ) -> sort( To_be_sorted, [], true ).
|
||||
|
||||
task() ->
|
||||
List = "asdqwe123",
|
||||
Sorted = list( List ),
|
||||
io:fwrite( "List ~p is sorted ~p~n", [List, Sorted] ).
|
||||
|
||||
|
||||
sort( [], Acc, true ) -> lists:reverse( Acc );
|
||||
sort( [], Acc, false ) -> sort( lists:reverse(Acc), [], true );
|
||||
sort( [X, Y | T], Acc, _Done ) when X > Y -> sort( [X | T], [Y | Acc], false );
|
||||
sort( [X | T], Acc, Done ) -> sort( T, [X | Acc], Done ).
|
||||
Loading…
Add table
Add a link
Reference in a new issue