Course of Raku / Advanced / More about built-in types / Sets, bags, and mixes / Exercises

Count the distinct

Problem

You are given a list of numbers, some of which repeat:

my @data = 3, 1, 4, 1, 5, 9, 2, 6, 5, 3;

Print how many distinct values it contains. Use a set.

Example

The program prints:

7

Solution

See the solution

Course navigation

Bags and mixes   |   Solution: Count the distinct