IBAN: Difference between revisions
Content added Content deleted
(→{{header|Perl 6}}: proposing a more idiomatic version (using a subset of Str)) |
(→{{header|Perl 6}}: shortening a bit) |
||
Line 462: | Line 462: | ||
=={{header|Perl 6}}== |
=={{header|Perl 6}}== |
||
<lang perl6>subset IBAN of Str where sub ($_ is copy) { |
<lang perl6>subset IBAN of Str where sub ($_ is copy) { |
||
s:g/\s//; |
|||
⚫ | |||
AD 24 AE 23 AL 28 AT 20 AZ 28 BA 20 BE 16 BG 22 BH 22 BR 29 CH 21 |
AD 24 AE 23 AL 28 AT 20 AZ 28 BA 20 BE 16 BG 22 BH 22 BR 29 CH 21 |
||
CR 21 CY 28 CZ 24 DE 22 DK 18 DO 28 EE 20 ES 24 FI 18 FO 18 FR 27 |
CR 21 CY 28 CZ 24 DE 22 DK 18 DO 28 EE 20 ES 24 FI 18 FO 18 FR 27 |
||
Line 469: | Line 470: | ||
MK 19 MR 27 MT 31 MU 30 NL 18 NO 15 PK 24 PL 28 PS 29 PT 25 RO 24 |
MK 19 MR 27 MT 31 MU 30 NL 18 NO 15 PK 24 PL 28 PS 29 PT 25 RO 24 |
||
RS 22 SA 24 SE 24 SI 19 SK 24 SM 27 TN 24 TR 26 VG 24 |
RS 22 SA 24 SE 24 SI 19 SK 24 SM 27 TN 24 TR 26 VG 24 |
||
>; |
>.hash{.substr(0,2).uc}; |
||
s:g/\s//; |
|||
⚫ | |||
my $country = .substr(0,2).uc; |
|||
return False unless %len{$country} and .chars == %len{$country}; |
|||
s/(.**4)(.+)/$1$0/; |
s/(.**4)(.+)/$1$0/; |
||
Line 481: | Line 476: | ||
} |
} |
||
⚫ | |||
⚫ | |||
'GB82 WEST 1234 5698 7654 32', |
|||
'gb82 west 1234 5698 7654 32', |
|||
⚫ | |||
{ |
|||
⚫ | |||
}</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |