You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-16Lines changed: 29 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,7 +121,7 @@ or
121
121
USAGE
122
122
=====
123
123
124
-
(See also the README file and several example scripts include with this module.)
124
+
(See several example scripts include with this module.)
125
125
126
126
This module now provides an object-oriented interface that uses less memory and is easier to use than most of the previous procedural interfaces. It also still provides several exportable functions. We'll deal with these in ascending order of difficulty: `LCS`, `LCS_length`, `LCSidx`, OO interface, `prepare`, `diff`, `sdiff`, `traverse_sequences`, and `traverse_balanced`.
Actually, `Next` returns the object's new position, which is a number between 1 and the number of hunks (inclusive), or returns a false value.
220
221
221
-
* Prev
222
+
Prev
223
+
----
222
224
223
225
`Prev($N)` is almost identical to `Next(-$N)`; it moves to the $Nth previous hunk. On a 'reset' object, `Prev()`[and `Next(-1)`] move to the last hunk.
224
226
225
227
The position returned by `Prev` is relative to the *end* of the hunks; -1 for the last hunk, -2 for the second-to-last, etc.
226
228
227
-
*`Reset`
229
+
`Reset`
230
+
-------
228
231
229
232
```raku
230
233
$diff.Reset; # Reset the object's position
@@ -235,7 +238,8 @@ $diff.Reset(-1); # Move to the last hunk
235
238
236
239
`Reset` returns the object, so, for example, you could use `$diff.Reset().Next(-1) ` to get the number of hunks.
237
240
238
-
* Copy
241
+
Copy
242
+
----
239
243
240
244
```raku
241
245
$copy=$diff.Copy( $newPos, $newBase );
@@ -271,35 +275,38 @@ $copy = $diff.Copy(0);
271
275
$copy=$diff.Copy.Reset;
272
276
```
273
277
274
-
* Diff
278
+
Diff
279
+
----
275
280
276
281
```raku
277
282
$bits=$obj.Diff;
278
283
```
279
284
280
285
`Diff` returns a true value iff the current hunk contains items that are different between the two sequences. It actually returns one of the follow 4 values:
281
286
282
-
* 3
287
+
###3
283
288
284
289
`3==(1|2)`. This hunk contains items from @seq1 and the items from @seq2 that should replace them. Both sequence 1 and 2 contain changed items so both the 1 and 2 bits are set.
285
290
286
-
* 2
291
+
###2
287
292
288
293
This hunk only contains items from @seq2 that should be inserted (not items from @seq1). Only sequence 2 contains changed items so only the 2 bit is set.
289
294
290
-
* 1
295
+
###1
291
296
292
297
This hunk only contains items from @seq1 that should be deleted (not items from @seq2). Only sequence 1 contains changed items so only the 1 bit is set.
293
298
294
-
* 0
299
+
###0
295
300
296
301
This means that the items in this hunk are the same in both sequences. Neither sequence 1 nor 2 contain changed items so neither the 1 nor the 2 bits are set.
297
302
298
-
* Same
303
+
Same
304
+
----
299
305
300
306
`Same` returns a true value iff the current hunk contains items that are the same in both sequences. It actually returns the list of items if they are the same or an emty list if they aren't. In a scalar context, it returns the size of the list.
301
307
302
-
* Items
308
+
Items
309
+
-----
303
310
304
311
```raku
305
312
$count=$diff.Items(2);
@@ -320,7 +327,8 @@ Otherwise, the hunk contains identical items and all of the following will retur
320
327
@items=$diff.Same;
321
328
```
322
329
323
-
* Range
330
+
Range
331
+
-----
324
332
325
333
```raku
326
334
$count=$diff.Range( $seqNum );
@@ -342,7 +350,8 @@ You can also specify the base to use as the second argument. So the following tw
`Base` sets and/or returns the current base (usually 0 or 1) that is used when you request range information. The base defaults to 0 so that range information is returned as array indices. You can set the base to 1 if you want to report traditional line numbers instead.
0 commit comments