@@ -481,6 +481,16 @@ character removed.
481
481
482
482
say 'perl'.chop; # per
483
483
484
+ = head2 method chomp
485
+
486
+ method chomp()
487
+
488
+ Coerces the invocant to L < Str|/type/Str > , and returns it with the last
489
+ character removed, if it is a logical newline.
490
+
491
+ say 'ab'.chomp.chars; # 2
492
+ say "a\n".chomp.chars; # 1
493
+
484
494
= head2 routine substr
485
495
486
496
method substr($from, $chars?)
@@ -505,6 +515,33 @@ relative to the end:
505
515
506
516
say 20151224.substr(*-2); # 24
507
517
518
+ = head2 routine ords
519
+
520
+ method ords()
521
+ sub ords(Str(Cool) $str)
522
+
523
+ Coerces the invocant (or in the sub form, the first argument) to
524
+ L < Str|/type/Str > , and returns a list of Unicode codepoints for each character.
525
+
526
+ say "Perl 6".ords; # 80 101 114 108 32 54
527
+ say ords 10; # 49 48
528
+
529
+ This is the list-returning version of L < ord > . The inverse operation in
530
+ L < chrs > .
531
+
532
+ = head2 routine chrs
533
+
534
+ method chrs()
535
+ sub chrs(*@codepoints) return Str:D
536
+
537
+ Coerces the invocant (or in the sub form, the argument list) to a list of
538
+ integers, and returns the string created by interpreting each integer as a
539
+ Unicode codepoint, and joining the characters.
540
+
541
+ say <80 101 114 108 32 54>.chrs; # Perl 6
542
+
543
+ This is the list-input version of L < chr > . The inverse operation is L < ords > .
544
+
508
545
= head2 method IO
509
546
510
547
method IO() returns IO::Path:D
@@ -517,7 +554,7 @@ Coerces the invocant to L<IO::Path>.
517
554
518
555
TODO: sech, asech, cosech, acosech, cotanh, acotanh, cis, roots, log10,
519
556
unpolar, truncate, fmt, substr-rw,
520
- chomp, chrs, trans, index, rindex, ords ,
557
+ trans, index, rindex,
521
558
split, match, comb, lines, words, subst, sprintf, printf, samecase,
522
559
EVAL
523
560
0 commit comments