From 63c3043200de6b28a8c192f1b5625940435ea55e Mon Sep 17 00:00:00 2001 From: Jed Barber Date: Sat, 17 Oct 2015 14:20:48 +1100 Subject: Organised source code a bit, added makefile with clean target --- selection.adb | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 selection.adb (limited to 'selection.adb') diff --git a/selection.adb b/selection.adb deleted file mode 100644 index 1b49769..0000000 --- a/selection.adb +++ /dev/null @@ -1,42 +0,0 @@ - - -package body Selection is - - - procedure Swap(A, B : in out Element_T) is - Temp : Element_T; - begin - Temp := A; - A := B; - B := Temp; - end Swap; - - - function Find_Largest(Arr : in Array_T) return Index_T is - Max : Index_T; - begin - Max := Arr'First; - for P in Index_T range Index_T'Succ(Arr'First) .. Arr'Last loop - if Arr(P) > Arr(Max) then - Max := P; - end if; - end loop; - return Max; - end Find_Largest; - - - procedure Sort(Arr : in out Array_T) is - Largest : Index_T; - begin - if Arr'Length <= 1 then - return; - end if; - - Largest := Find_Largest(Arr); - Swap( Arr(Arr'Last), Arr(Largest) ); - Sort( Arr(Arr'First .. Index_T'Pred(Arr'Last)) ); - end Sort; - - -end Selection; - -- cgit