« lib/MLPerl/Config.pm
↑ Summary
lib/MLPerl/Test/ClassifierKNeighbors2DBrute/program_00_125_125_250_good.pl »
| 1 | # [[[ HEADER ]]] | ||
| 2 | use RPerl; | ||
| 3 | package MLPerl::PythonShims; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | our $VERSION = 0.001_000; | ||
| 7 | |||
| 8 | # [[[ CRITICS ]]] | ||
| 9 | ## no critic qw(ProhibitUselessNoCritic ProhibitMagicNumbers RequireCheckedSyscalls) # USER DEFAULT 1: allow numeric values & print operator | ||
| 10 | ## no critic qw(RequireInterpolationOfMetachars) # USER DEFAULT 2: allow single-quoted control characters & sigils | ||
| 11 | |||
| 12 | # [[[ EXPORTS ]]] | ||
| 13 | use RPerl::Exporter qw(import); | ||
| 14 | our @EXPORT_OK = qw(concatenate range for_range); | ||
| 15 | |||
| 16 | # [[[ SUBROUTINES ]]] | ||
| 17 | |||
| 18 | # NEED FIX: move all subroutines to some appropriate library file | ||
| 19 | sub concatenate { | ||
| 20 | { my number_arrayref $RETURN_TYPE }; | ||
| 21 | ( my number_arrayref $input_0, my number_arrayref $input_1 ) = @ARG; | ||
| 22 | return [@{$input_0}, @{$input_1}]; | ||
| 23 | } | ||
| 24 | |||
| 25 | |||
| 26 | # range(start, stop, step) # PYTHON | ||
| 27 | # NEED UPGRADE: enable all 3 input parameters | ||
| 28 | sub range { | ||
| 29 | { my integer_arrayref $RETURN_TYPE }; | ||
| 30 | # ( my integer $start, my integer $stop, my integer $step ) = @ARG; | ||
| 31 | ( my integer $stop ) = @ARG; | ||
| 32 | return [0 .. ($stop - 1)]; | ||
| 33 | } | ||
| 34 | |||
| 35 | |||
| 36 | # NEED FIX: creates strings instead of integers, which do we want??? | ||
| 37 | # create arrayref of integer repeated a certain number of times | ||
| 38 | sub for_range { | ||
| 39 | { my string_arrayref $RETURN_TYPE }; | ||
| 40 | ( my string $input, my integer $repetitions ) = @ARG; | ||
| 41 | # print 'in for_range(), received $input = ', $input, "\n"; | ||
| 42 | # print 'in for_range(), received $repetitions = ', $repetitions, "\n"; | ||
| 43 | |||
| 44 | my string_arrayref $input_repeated = []; | ||
| 45 | |||
| 46 | for (my integer $i = 0; $i < $repetitions; $i++) { | ||
| 47 | $input_repeated->[$i] = $input; | ||
| 48 | } | ||
| 49 | return $input_repeated; | ||
| 50 | } | ||
| 51 | |||
| 52 | 1; # end of package |