Skip to content

Commit

Permalink
fix: Array::unique
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyfettes committed Oct 6, 2024
1 parent 285d176 commit 68f9c38
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions builtin/array.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -843,13 +843,9 @@ pub fn dedup[T : Eq](self : Array[T]) -> Unit {
/// v.unique() // v = [3, 4, 5, 6, 4]
/// ```
pub fn unique[T : Eq](self : Array[T]) -> Unit {
for i in 0..<self.length() {
for j = i + 1; j < self.length(); j = j + 1 {
if self[i] == self[j] {
self.remove(j) |> ignore
} else {
break
}
for i = 0; i < self.length(); i = i + 1 {
while i + 1 < self.length() && self[i] == self[i + 1] {
self.remove(i + 1) |> ignore
}
}
}
Expand Down

0 comments on commit 68f9c38

Please sign in to comment.