I thought you wanted them sorted also? [1] > (8,7,6,7,5,4,2,1).unique (8 7 6 5 4 2 1) [2] > (8,7,6,7,5,4,2,1).unique.sort (1 2 4 5 6 7 8)
-y On Mon, May 6, 2024 at 6:15 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 5/6/24 03:07, ToddAndMargo via perl6-users wrote: > > > >>> On 6 May 2024, at 04:35, ToddAndMargo via perl6-users > >>> <perl6-us...@perl.org> wrote: > >>> > >>> Hi All, > >>> > >>> I have thought of how to do it and pretty sure > >>> it would work, but just in case Raku have one > >>> of those sweet utilities, does Raku have a > >>> utility that will take an array and remove all > >>> the duplicates and rearrange the cells back > >>> in order? > >>> > >>> Many thanks, > >>> -T > > > > On 5/6/24 01:59, Elizabeth Mattijsen wrote: > > > $ raku -e 'my @a = 1,2,3,6,7,1,2,8; @a .= unique; say @a' > > > [1 2 3 6 7 8] > > > > > > https://docs.raku.org/type/Any#method_unique > > > > > > > I knew there had to be something! Thank you! > > My keeper: perl6.array.duplicates.unique.txt > > > Raku (perl6): how to remove duplicates from an array: > > Use `unique` and `.=` > > For example: > > $ raku -e 'my @a = 1,2,3,6,7,1,2,8; @a .= unique; say @a' > [1 2 3 6 7 8] > > $ raku -e 'my @a = "abc","DEF","abc","jkl",1,2,8; @a .= unique; say @a' > [abc DEF jkl 1 2 8] > > $ raku -e 'my @a = "abc","DEF","abc","jkl",1; @a .= unique; say @a' > [abc DEF jkl 1] > > $ raku -e 'my @a = "abc","DEF","abc","jkl",1,8,1,2,8; @a .= unique; say @a' > [abc DEF jkl 1 8 2] > > >