Documentation for routine
squish assembled from the following types:
method squish(:, : --> Seq)
say Any.squish; # OUTPUT: «((Any))␤»
multi sub squish(*, :, : --> Seq)multi method squish(List: :, : --> Seq)
Returns a sequence of values from the invocant/argument list where runs of more than one value are replaced with only the first instance. Like
squish uses the semantics of the === operator to decide whether two objects are the same. Unlike
unique, this function only removes adjacent duplicates; identical values further apart are still kept. The order of the original list is preserved even as duplicates are removed.
say <a a b b b c c>.squish; # OUTPUT: «(a b c)␤»say <a b b c c b a>.squish; # OUTPUT: «(a b c b a)␤»
:as parameter, just like with
unique, allows values to be temporarily transformed before comparison.
:with parameter is used to set an appropriate comparison operator:
say [42, "42"].squish; # OUTPUT: «(42 42)␤»# Note that the second item in the result is still Strsay [42, "42"].squish(with => :<eq>); # OUTPUT: «(42)␤»# The resulting item is Int
method squish(Supply: :, : --> Supply)
Creates a supply that only provides unique values, as defined by the optional
:with parameters (same as with List.squish).