Skip to content

Commit

Permalink
Merge pull request #377 from LilJordan23/main
Browse files Browse the repository at this point in the history
change "~"sign into back of the word.md
  • Loading branch information
bobzhang authored Dec 20, 2024
2 parents 2762520 + 50883d8 commit 9133f97
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ guard let Node(x, y) = z

```moonbit
enum Data {
Data(~sum : Int, ~len : Int)
Data(sum~ : Int, len~ : Int)
} derive(Show)
enum LazyTag {
Expand All @@ -70,7 +70,7 @@ enum LazyTag {
enum Node {
Nil
Node(~data : Data, ~tag : LazyTag, ~left : Node, ~right : Node)
Node(data~ : Data, tag~ : LazyTag, left~ : Node, right~ : Node)
} derive(Show)
```

Expand Down Expand Up @@ -132,12 +132,12 @@ fn op_add(self : LazyTag, v : LazyTag) -> LazyTag {
fn apply(self : Node, v : LazyTag) -> Node {
match (self, v) {
(Node(data=Data(sum=a, len=length), ~tag, ~left, ~right), Tag(v) as new_tag) =>
(Node(data=Data(sum=a, len=length), tag~, left~, right~), Tag(v) as new_tag) =>
Node(
data=Data(sum=a + v * length, len=length),
tag=tag + new_tag,
~left,
~right,
left~,
right~,
)
(_, Nil) => self
(Nil, _) => Nil
Expand All @@ -163,7 +163,7 @@ fn modify(
} else if modify_l <= l && modify_r >= r {
self.apply(tag)
} else {
guard let Node(~left, ~right, ..) = self
guard let Node(left~, right~, ..) = self
left.apply(tag) + right.apply(tag)
}
}
Expand Down Expand Up @@ -213,7 +213,7 @@ fn query(self : Node, l : Int, r : Int, query_l : Int, query_r : Int) -> Node {
} else if query_l <= l && query_r >= r {
self
} else {
guard let Node(~tag, ~left, ~right, ..) = self
guard let Node(tag~, left~, right~, ..) = self
let mid = (l + r) >> 1
left.apply(tag).query(l, mid, query_l, query_r) +
right.apply(tag).query(mid + 1, r, query_l, query_r)
Expand Down

0 comments on commit 9133f97

Please sign in to comment.