aboutsummaryrefslogtreecommitdiff
path: root/challenge-201/luca-ferrari/postgresql/ch-2.plperl
blob: 68cfb36d32b8b04bffc142b7c03a5c7cf1eeebf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
--
-- Perl Weekly Challenge 201
-- Task 2
-- See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-201/>
--

CREATE SCHEMA IF NOT EXISTS pwc201;

CREATE OR REPLACE FUNCTION
pwc201.task2_plperl( int)
RETURNS int
AS $CODE$

  use Integer::Partition;
  my $partitions = Integer::Partition->new( $_[0] );
  my $count = 0;
  $count++  while( $partitions->next );
  return $count;
$CODE$
LANGUAGE plperlu;