Skip to content

Commit f5f8e4b

Browse files
committed
Clarify usage of slicing operators
1 parent c485ce3 commit f5f8e4b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

docs/src/values.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,21 @@ <h3>Binary Operators</h3>
4545
Concatenation.
4646
</li>
4747
<li><code>§</code> (<em>Number</em>, <em>Text</em>) → <em>Text</em><br>
48-
Left slice.
48+
Left slice: only retain characters after the position specified by the left argument (positive: count from left; negative: count from right).
4949
</li>
5050
<li><code>§</code> (<em>Text</em>, <em>Number</em>) → <em>Text</em><br>
51-
Right slice.
51+
Right slice: only retain characters before the position specified by the right argument (positive: count from left; negative: count from right).
5252
</li>
5353
</ul>
5454
</div>
5555

5656
<div class="demo">
5757
<h3>Examples</h3>
5858
<ul class="convert">
59-
<li><code>{t § 3}</code> (<code>t = </code><code class="cval">foobar</code>)</li>
6059
<li><code>{3 § t}</code> (<code>t = </code><code class="cval">foobar</code>)</li>
60+
<li><code>{-2 § t}</code> (<code>t = </code><code class="cval">foobar</code>)</li>
61+
<li><code>{t § 3}</code> (<code>t = </code><code class="cval">foobar</code>)</li>
62+
<li><code>{t § -2}</code> (<code>t = </code><code class="cval">foobar</code>)</li>
6163
<li><code>{(2 § t) § 3}</code> (<code>t = </code><code class="cval">foobar</code>)</li>
6264
<li><code>{2 § (t § 3)}</code> (<code>t = </code><code class="cval">foobar</code>)</li>
6365
</ul>

test/test_values.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ describe("Value operators", function () {
167167
["-3 § foo ", "ijk"],
168168
[" foo § 3", "abc"],
169169
[" foo § -3", "abcdefgh"],
170+
[" 3 § foo § 3", "def"],
171+
["-3 § foo § 1", "i"],
172+
[" 3 § foo § -2", "defghi"],
173+
["-3 § foo § -2", "i"],
174+
["-3 § foo § -4", ""]
170175
], [
171176
["foo", new TextValue("abcdefghijk")]
172177
]));

0 commit comments

Comments
 (0)