Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,16 @@
sub fulfill {
my @payloads;
push @payloads, 'Payload#' . $_ for 0..5;
my @result;
push @result, ref $_ eq 'ARRAY' ? [@payloads[@$_]] : @payloads[$_] for @{@_[0]};
return [@result];
}
sub formatted {
my $result;
$result .= ref $_ eq 'ARRAY' ? '[ "'. join('", "', @$_) . '" ], ' : qq{"$_"} for @{@_[0]};
return '[ ' . $result . " ]\n";
}
print formatted fulfill( [[1,2], [ 3,4,1], 5] );
print formatted fulfill( [[1,2], [10,4,1], 5] );

View file

@ -0,0 +1,22 @@
#!/usr/bin/perl
use strict; # https://rosettacode.org/wiki/Nested_templated_data
use warnings;
use Data::Dump 'dd';
my $t = [
[[1, 2],
[3, 4, 1],
5]];
my $p = [ map "Payload#$_", 0 .. 6 ];
dd { 'template' => $t, 'payload' => $p };
my $output = filltemplate( $t, $p );
dd { 'output' => $output };
sub filltemplate
{
my ($t, $p) = @_;
return ref $t eq 'ARRAY' ? [ map filltemplate($_, $p), @$t ] : $p->[$t];
}