routine squish

Documentation for routine squish assembled from the following types:

class Any

From Any

(Any) method squish

Defined as:

method squish(:&as:&with --> Seq)

Coerces the invocant to a list by applying its .list method and uses List.squish on it.

say Any.squish# OUTPUT: «((Any))␤» 

class List

From List

(List) routine squish

Defined as:

multi sub    squish(*@values:&as:&with --> Seq:D)
multi method squish(List:D:   :&as:&with --> Seq:D)

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 unique, 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)␤» 

The optional :as parameter, just like with unique, allows values to be temporarily transformed before comparison.

The optional :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 Str 
say [42"42"].squish(with => &infix:<eq>); # OUTPUT: «(42)␤» 
# The resulting item is Int 

class Supply

From Supply

(Supply) method squish

method squish(Supply:D: :$as:$with --> Supply:D)

Creates a supply that only provides unique values, as defined by the optional :as and :with parameters (same as with List.squish).