# routine repeated

Documentation for routine `repeated`

assembled from the following types:

# class routines

From routines

## (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.

# 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.