Skip to content

Commit

Permalink
Update MR.md
Browse files Browse the repository at this point in the history
  • Loading branch information
linsyking authored Apr 5, 2023
1 parent 8dbb0a8 commit 9f2ec68
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions docs/MR.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Multiple Replacement

It is easy to replace one string with another in meow. However, when you want to replace multiple strings with multiple strings, it is not that easy. This is because the replacement is done in a single pass.
It is easy to replace one string with another in meow. However, when you want to replace multiple strings with multiple strings, it is not that easy. This is because the replacement is done one by one.

For example,

Expand All @@ -9,11 +9,11 @@ For example,
bb
```

We want to replace `a` with `b` and `c` with `a`. However, the replacement is done in a single pass, so the first replacement is done, and then the second replacement is done. So, the result is `bb`.
We want to replace `a` with `b` and `c` with `a`. However, the replacement is done one by one, so the first replacement is done, and then the second replacement is done. So, the result is `bb`.

What if we want to do the replacement simultaneously? It's not easy to see.

This feature doesn't need i expression and it is originally designed to be supported in catlet.
This feature doesn't need recursion and it is originally designed to be supported in catlet.

First, we have to make sure that the multiple strings are all **independent**. Otherwise the result is not expected.

Expand Down Expand Up @@ -45,3 +45,5 @@ rep2(s,x,xr,y,yr) {
})
}
```

Result for `rep2 "ac" "a" "b" "c" "a"` is `"ba"`.

0 comments on commit 9f2ec68

Please sign in to comment.