aboutsummaryrefslogtreecommitdiff
path: root/challenge-199
diff options
context:
space:
mode:
authorLuca Ferrari <fluca1978@gmail.com>2023-01-09 10:02:23 +0100
committerLuca Ferrari <fluca1978@gmail.com>2023-01-09 10:02:23 +0100
commitdec095313737f0489797225861addabcf8e5a4f0 (patch)
tree2ea3998b37fc6a4a0e15f2dc7406dbc7c4c55878 /challenge-199
parentaa53c8f739c6435b7d545b68ccd72a73e1e5d331 (diff)
downloadperlweeklychallenge-club-dec095313737f0489797225861addabcf8e5a4f0.tar.gz
perlweeklychallenge-club-dec095313737f0489797225861addabcf8e5a4f0.tar.bz2
perlweeklychallenge-club-dec095313737f0489797225861addabcf8e5a4f0.zip
Task 1 plperl
Diffstat (limited to 'challenge-199')
-rw-r--r--challenge-199/luca-ferrari/postgresql/ch-1.plperl24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-199/luca-ferrari/postgresql/ch-1.plperl b/challenge-199/luca-ferrari/postgresql/ch-1.plperl
new file mode 100644
index 0000000000..7b91f9a3f9
--- /dev/null
+++ b/challenge-199/luca-ferrari/postgresql/ch-1.plperl
@@ -0,0 +1,24 @@
+-- Perl Weekly Challenge 199
+-- Task 1
+
+CREATE SCHEMA IF NOT EXISTS pwc199;
+
+CREATE OR REPLACE FUNCTION
+pwc199.task1_plperl( int[] )
+RETURNS int
+AS $CODE$
+
+ my ( $list ) = @_;
+ my @pairs;
+
+ for my $i ( 0 .. $list->@* ) {
+ for my $j ( $i .. $list->@* ) {
+ next if $i == $j;
+ push @pairs, [ $i, $j ] if ( $list->[ $i ] == $list->[ $j ] );
+ }
+ }
+
+ return scalar @pairs;
+
+$CODE$
+LANGUAGE plperl;