@@ -455,12 +455,14 @@ C<is canonicalized(&lc)>.)
455
455
456
456
Returns a list of unique values from the invocant/argument
457
457
list. C<uniq> uses C<< &infix:<===> >> semantics to compare whether
458
- two objects are the same. The function does not use C<===> directly,
459
- however; it is actually implemented via an object-keyed hash (such as
460
- an object set), so that any instance of a given identity suppresses all
461
- subsequent instances of that identity, even if they are not contiguous
462
- in the list. (Use C<squish> instead if you know the input is sorted
463
- such that identical objects are adjacent.)
458
+ two objects are the same. The order of the original list is preserved
459
+ even as duplicates are removed.
460
+
461
+ say <a a b b b c c>.uniq # a b c
462
+ say <a b b c c b a>.uniq # a b c
463
+
464
+ (Use C<squish> instead if you know the input is sorted such that identical
465
+ objects are adjacent.)
464
466
465
467
=item squish
466
468
@@ -471,9 +473,13 @@ such that identical objects are adjacent.)
471
473
Returns a list of values from the invocant/argument list where runs
472
474
of more than one object of the same identity are squished down to
473
475
a single instance. Like C<uniq>, C<squish> uses C<< &infix:<===> >>
474
- semantics to compare whether two objects are the same. Unlike,
475
- C<uniq>, this function does not need to keep a hash of all previous
476
- identities; it simply tracks the previous one, and uses C<===> directly.
476
+ semantics to compare whether two objects are the same. Unlike
477
+ C<uniq>, this function only removes adjacent duplicates; identical
478
+ objects further apart are still kept. The order of the original list
479
+ is preserved even as duplicates are removed.
480
+
481
+ say <a a b b b c c>.squish # a b c
482
+ say <a b b c c b a>.squish # a b c b a
477
483
478
484
=item min
479
485
0 commit comments