in reply to Check if string A and B are made up of same chars
Variety delights:
#!/usr/bin/env perl use strict; use warnings; use Set::Scalar; use List::MoreUtils qw(uniq); use feature qw(say); my $string = qw(kizuaheli); my $s_1 = Set::Scalar->new(uniq(split//, $string)); my $s_2 = Set::Scalar->new(uniq(split//, $string)); say $s_1->is_equal($s_2); say $s_1 == $s_2; my $s_3 = Set::Scalar->new(uniq(split//, $string)); my $s_4 = Set::Scalar->new(uniq(split//, "")); say $s_3->is_equal($s_4); say $s_3 == $s_4;
Update: arunbear has pointed out that the use of uniq is superfluous here - see below.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Check if string A and B are made up of same chars
by Arunbear (Prior) on Nov 18, 2024 at 11:24 UTC | |
by karlgoethebier (Abbot) on Nov 18, 2024 at 16:19 UTC | |
|
Re^2: Check if string A and B are made up of same chars
by LanX (Saint) on Nov 17, 2024 at 17:42 UTC | |
by karlgoethebier (Abbot) on Nov 17, 2024 at 17:54 UTC | |
by LanX (Saint) on Nov 17, 2024 at 19:09 UTC |