Skip to content

Commit ec1cbd9

Browse files
committed
Add vim coda to perlmonks examples
1 parent a10e4f8 commit ec1cbd9

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

perlmonks/combinations-731808.pl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
# Given a list of URL prefixes, and a list of product IDs, make a list
66
# consisting of each URL prefix concatenated with each product ID.
77

8-
98
my @urls = ('http://www.something.com/blah.aspx?code=',
109
'http://www.somethingelse.com/stuff.aspx?thing=');
1110

1211
my @ids = <375035304 564564774 346464646>;
1312

14-
1513
# 1. Cross then map
1614
# We use the cross operator X to make every combination of pairs from @urls
1715
# and @ids. We then use map to stringify each pair. $^a is a "placeholder
@@ -27,5 +25,6 @@
2725
# You can use any infix operator.
2826
# Try (1,2,3) X* (1,2,3) to generate a multiplication table.
2927

30-
3128
.say for @urls X~ @ids;
29+
30+
# vim: expandtab shiftwidth=4 ft=perl6

perlmonks/weighted-roll-731696.pl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@
3737
my $total = [+] @weights;
3838
say "Total Weights $total";
3939

40-
sub pick (@weights, $total) {
40+
sub pick(@weights, $total) {
4141
my $rand = (0..^$total).pick;
4242
for @weights.kv -> $i, $w {
4343
$rand -= $w;
4444
return $i if $rand < 0;
4545
}
4646
}
4747

48-
sub pickAll (@weights is copy, $total is copy) {
48+
sub pickAll(@weights is copy, $total is copy) {
4949
my @order;
5050
for @weights {
5151
my $pick = pick(@weights, $total);
@@ -58,5 +58,4 @@ (@weights is copy, $total is copy)
5858

5959
say ~pickAll(@weights,$total) for 1 .. $REPS;
6060

61-
62-
61+
# vim: expandtab shiftwidth=4 ft=perl6

0 commit comments

Comments
 (0)