Allow <= and >= as overloadable operators and add in a string <= function (though some refactoring to do <, >, and => would be good) and a sorted to vec
This commit is contained in:
@@ -206,6 +206,23 @@ obj str (Object, Serializable, Hashable) {
|
||||
var str.construct(other) : str
|
||||
return *this == str
|
||||
}
|
||||
fun operator<=(other: ref str): bool {
|
||||
var l = 0
|
||||
var r = 0
|
||||
while (l < length() || r < other.length()) {
|
||||
if l == length() {
|
||||
return true
|
||||
} else if r == other.length() {
|
||||
return false
|
||||
} else if (*this)[l] < other[r] {
|
||||
return true
|
||||
} else if (*this)[l] > other[r] {
|
||||
return false
|
||||
}
|
||||
l++
|
||||
r++
|
||||
}
|
||||
}
|
||||
|
||||
fun operator*(n: int): str {
|
||||
var to_ret.construct(): str
|
||||
|
||||
Reference in New Issue
Block a user