From 967be9e750221ab2ab783f95df79bb26d290a45e Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:07:58 +0200 Subject: add: added projects --- tigrou/sort/sort.tih | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tigrou/sort/sort.tih (limited to 'tigrou/sort/sort.tih') diff --git a/tigrou/sort/sort.tih b/tigrou/sort/sort.tih new file mode 100644 index 0000000..c601fe3 --- /dev/null +++ b/tigrou/sort/sort.tih @@ -0,0 +1,24 @@ +type int_array = array of int +function sort(a : int_array, size : int) = + if size > 0 then + ( + let var swapped := 0 + in + for i := 0 to size do + ( + swapped := 0; + (for j := 1 to size - i - 1 do + if a[j - 1] > a[j] then + ( + (let var tmp := a[j - 1] + in + a[j - 1] := a[j]; + a[j] := tmp + end); + swapped := 1 + )); + if swapped = 0 then + break + ) + end + ) -- cgit v1.2.3