[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-543-gaaff9c0
Benoit Sonntag
sonntag at icps.u-strasbg.fr
Sat Nov 21 13:29:16 UTC 2009
The following commit has been merged in the master branch:
commit aaff9c04fdc1c923268fb62ab897cbcd912874c6
Author: Benoit Sonntag <sonntag at icps.u-strasbg.fr>
Date: Sat Nov 21 14:29:05 2009 +0100
essai
diff --git a/lib/standard/collection/fast_array.li b/lib/standard/collection/fast_array.li
index 969464b..0fed681 100644
--- a/lib/standard/collection/fast_array.li
+++ b/lib/standard/collection/fast_array.li
@@ -340,39 +340,17 @@ Section Public
) ;
//
- // Sort
+ // Sort (BSBS: to put in ARRAYED_COLLECTION)
//
- bubble_sort <-
- // Bubble sort :-( => BSBS: Optmize with Quick sort...
- ( + low,up,idx,max:INTEGER;
- + sw:BOOLEAN;
-
- max := upper-1;
-
- low := 0;
- up := max;
- {
- sw:=FALSE;
- low.to up do { i:INTEGER;
- (item i > item (i+1)).if {
- swap i with (i+1);
- sw := TRUE;
- };
-
- idx := max - i;
- (item idx > item (idx+1)).if {
- swap idx with (idx+1);
- sw := TRUE;
- };
- };
- up := up - 1;
- low := low + 1;
- }.do_while {sw};
+ // Bubble sort
+ (
+ bubble_sort_with { (a,b:V); a > b};
);
- bubble_sort_with cmp:{ (V,V); BOOLEAN} <-
- // Bubble sort :-( => BSBS: Optmize with Quick sort...
+ // Bubble sort
( + low,up,idx,max:INTEGER;
+ sw:BOOLEAN;
@@ -399,6 +377,34 @@ Section Public
}.do_while {sw};
);
+ - quick_sort_from low:INTEGER to up:INTEGER <-
+ quick_sort_from low to up with { (a,b:V); a > b};
+
+ - quick_sort_from low:INTEGER to up:INTEGER with cmp:{ (V,V); BOOLEAN} <-
+ // Quick sort algorithm (naive implementation)
+ ( + i, p:INTEGER;
+ + pivot, tmp:INTEGER;
+
+ (up > low).if {
+ pivot := (low + up) >> 1;
+ swap pivot with low;
+ p := low;
+ (low+1).to up do { i:INTEGER;
+ (cmp.value (item low,item i)).if {
+ p := p + 1;
+ swap i with p;
+ };
+ };
+ swap p with low;
+ quick_sort_from low to (p - 1);
+ quick_sort_from (p + 1) to up;
+ };
+ );
+
+ - quick_sort <- quick_sort_from lower to upper;
+
+ - quick_sort_with cmp:{ (V,V); BOOLEAN} <- quick_sort_from lower to upper with cmp;
+
//
// Other.
//
diff --git a/lib/standard/string/abstract_string.li b/lib/standard/string/abstract_string.li
index 131a740..43f447c 100644
--- a/lib/standard/string/abstract_string.li
+++ b/lib/standard/string/abstract_string.li
@@ -170,6 +170,26 @@ Section Public
result
);
+ - Self:SELF '!<' other:ABSTRACT_STRING :BOOLEAN <-
+ // Is Current less than `other' ?
+ ( + i: INTEGER;
+ + result: BOOLEAN;
+
+ i := 1;
+ {(count < i) || {other.count < i} || {item i != other.item i}}.until_do {
+ i := i + 1;
+ };
+ (count < i).if {
+ result := other.count >= i;
+ } else {
+ (other.count < i).if {
+ result := FALSE;
+ };
+ result := item i < other.item i;
+ };
+ result
+ );
+
- compare other:ABSTRACT_STRING :INTEGER <-
// Compare alphabetically `Self' to `other'
( + i: INTEGER;
@@ -1322,4 +1342,3 @@ Section Public
);
-
diff --git a/src/lisaac.li b/src/lisaac.li
index aa79f0f..10b4ca0 100644
--- a/src/lisaac.li
+++ b/src/lisaac.li
@@ -82,7 +82,7 @@ Section Public
Section Private
- - version:STRING_CONSTANT := "0.39 beta";
+ - version:STRING_CONSTANT := "0.39";
//
//
@@ -298,6 +298,9 @@ Section Private
die_with_code exit_failure_code;
};
s.run_with NULL;
+ path_file.quick_sort_with { (a,b:STRING_CONSTANT);
+ a > b
+ };
(is_path_list).if {
string_tmp.clear;
--
Lisaac compiler
More information about the Lisaac-commits
mailing list