# routine repeated

Documentation for routine `repeated`

assembled from the following types:

# class Any

From Any

## (Any) method repeated

Defined as:

multi method repeated()multi method repeated( :!, :! )multi method repeated( :! )multi method repeated( :! )

Similarly to `unique`

, finds repeated elements in `values`

(as a routine) or in the object, using the `:as`

associative argument as a normalizing function and `:with`

as equality function.

<1 -1 2 -2 3>.repeated(:as(),:with(&[==])).say; # OUTPUT: «(-1 -2)»(3+3i, 3+2i, 2+1i).repeated(as => *.re).say; # OUTPUT: «(3+2i)»

It returns the last repeated element before normalization, as shown in the example above. See `repeated`

for more examples that use its sub form.

# class Supply

From Supply

## (Supply) method repeated

method repeated(Supply: :, :)

Creates a supply that only provides repeated values, as defined by the optional `:as`

and `:with`

parameters (same as with `unique`

).

my = Supply.from-list(<a A B b c b C>).repeated(:as());.tap(); # OUTPUT: «AbbC»

See `repeated`

for more examples that use its sub form.

**Note**: Available since version 6.e (Rakudo 2020.01 and later).

# language documentation Independent routines

From Independent routines

## (Independent routines) routine repeated

Defined as:

multi sub repeated(+values, |c)

This returns a sequence of **repeated** values from the invocant/argument list. It takes the same parameters as unique, but instead of passing through any elements when they're first seen, they're only passed through as soon as they're seen for the second time (or more).

Examples:

say <a a b b b c c>.repeated; # OUTPUT: «(a b b c)»say <a b b c c b a>.repeated; # OUTPUT: «(b c b a)»say <a A B b c b C>.repeated(:as()); # OUTPUT: «(A b b C)»my = %(a => 42), %(b => 13), %(a => 42);say .repeated(:with(&[eqv])) # OUTPUT: «({a => 42})»

As in the case of `unique`

the associative argument `:as`

takes a Callable that normalizes the element before comparison, and `:with`

takes a the equality comparison function that is going to be used.