@@ -335,7 +335,7 @@ element can not be coerced into Numeric.
335
335
method reverse(Range:D: --> Seq:D)
336
336
337
337
Returns a L < Seq|/type/Seq > where all elements that the C < Range > represents have
338
- been reversed. Note that reversing an infinite C < Range > won't produce any
338
+ been reversed. Note that reversing an infinite C <> won't produce any
339
339
meaningful results.
340
340
341
341
say (1^..5).reverse; # OUTPUT: «(5 4 3 2)»
@@ -379,6 +379,66 @@ C<self.elems>. Returns C<False> otherwise.
379
379
say (6..10).EXISTS-POS(2); # OUTPUT: «True»
380
380
say (6..10).EXISTS-POS(7); # OUTPUT: «False»
381
381
382
+ = head2 sub infix:<+>
383
+
384
+ multi sub infix:<+>(Range:D \r, Real:D \v)
385
+ multi sub infix:<+>(Real:D \v, Range:D \r)
386
+
387
+ Takes an L < C < Real > |/type/Real> and adds that number to both
388
+ boundaries of the L < Range|/type/Range > object. Be careful with
389
+ the use of parenthesis.
390
+
391
+ say (1..2) + 2; # OUTPUT: «3..4»
392
+ say 1..2 + 2; # OUTPUT: «1..4»
393
+
394
+ = head2 sub infix:<->
395
+
396
+ multi sub infix:<->(Range:D \r, Real:D \v)
397
+
398
+ Takes an L < C < Real > |/type/Real> and substract that number to both
399
+ boundaries of the L < Range|/type/Range > object. Be careful with
400
+ the use of parenthesis.
401
+
402
+ say (1..2) - 1; # OUTPUT: «0..1»
403
+ say 1..2 - 1; # OUTPUT: «1..1»
404
+
405
+ = head2 sub infix:<*>
406
+
407
+ multi sub infix:<*>(Range:D \r, Real:D \v)
408
+ multi sub infix:<*>(Real:D \v, Range:D \r)
409
+
410
+ Takes an L < C < Real > |/type/Real> and multiply both boundaries
411
+ of the L < Range|/type/Range > object by that number.
412
+
413
+ say (1..2) * 2; # OUTPUT: «2..4»
414
+
415
+ = head2 sub infix:</>
416
+
417
+ multi sub infix:</>(Range:D \r, Real:D \v)
418
+
419
+ Takes an L < Real|/type/Real > and divide both boundaries
420
+ of the L < Range|/type/Range > object by that number.
421
+
422
+ say (2..4) / 2; # OUTPUT: «1..2»
423
+
424
+ = head2 sub infix:<cmp>
425
+
426
+ multi sub infix:<cmp>(Range:D \a, Range:D \b --> Order:D)
427
+ multi sub infix:<cmp>(Num(Real) \a, Range:D \b --> Order:D)
428
+ multi sub infix:<cmp>(Range:D \a, Num(Real) \b --> Order:D)
429
+ multi sub infix:<cmp>(Positional \a, Range:D \b --> Order:D)
430
+ multi sub infix:<cmp>(Range:D \a, Positional \b --> Order:D)
431
+
432
+ Compares two L < Range|/type/Range > objects. If you use a L < C < Real > |/type/Real> ,
433
+ it will be compared to the L < Range|/type/Range > C < b..b > . If you use a
434
+ L < Positional > |/type/Positional>.
435
+
436
+ say (1..2) cmp (1..2) # OUTPUT: «Same»
437
+ say (1..2) cmp (1..3) # OUTPUT: «Less»
438
+ say (1..4) cmp (1..3) # OUTPUT: «More»
439
+ say (1..2) cmp 3 # OUTPUT: «Less»
440
+ say (1..2) cmp [1,2] # OUTPUT: «Same»
441
+
382
442
= end pod
383
443
384
444
# vim: expandtab softtabstop=4 shiftwidth=4 ft=perl6
0 commit comments