This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1) every time you don't use sigils you are hogging namespace for something thats not variables. Something close to keywords like | |
| "from" and "to" is a bad plan. I've seen several people including myself use "from $i to $j by $inc" as their own range/list constructing | |
| syntax. I have no idea if Rakudo is smart enough to negotiate sigiless variables and keywords at the same time, Id almost hope its not! | |
| 2) to some extent it doesn't matter if the OP finds it easier to read or if you do, almost the entirety of code you will come | |
| across will not use that convention. So learning that way to start out with is only going to cause pain working with others. Just wanting | |
| to write a debug statement for that whats the simple plan? say "from {from} to {to}" not so clean given the norm for the language... You're | |
| changing *semantics* for the sake of visual aesthetic not readability. Your intent is less clear given the language, its less readable but | |
| perhaps prettier. | |
| 3) friendlier for the OP to learn a language which isn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl6 | |
| use v6; | |
| use Stats; | |
| #Quick benchmark script for https://www.reddit.com/r/perl6/comments/8tdfvz/handwavy_speed_test/ | |
| # $ perl6 annual-rate.p6 --upto=100 | |
| # annual-rate-with-helper: ran in 0.0551038961038961 seconds (σ = 0.015335042908917152 seconds) | |
| # Result was 1.3232569411493311 | |
| # annual-rate-rat-exp: ran in 0.7545948945615983 seconds (σ = 0.03632803218476478 seconds) | |
| # Result was 1.3232569411482977 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| use strict; | |
| use warnings; | |
| open my $file, '<', '../../example-input.csv'; | |
| while(my $record = <$file>) { | |
| chomp $record; | |
| my ($ElementId, $VehicleId, $Term, $Mileage, $Value) = split ',', $record; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| In [37]: date = datetime.datetime.now() | |
| ...: pd.DataFrame(data={'value': {date:1.0}}).reindex(pd.date_range('2018-05-30','2018-06-15'), fill_value=0) | |
| Out[37]: | |
| value | |
| 2018-05-30 0.0 | |
| 2018-05-31 0.0 | |
| 2018-06-01 0.0 | |
| 2018-06-02 0.0 | |
| 2018-06-03 0.0 | |
| 2018-06-04 0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl6 | |
| %*SUB-MAIN-OPTS<named-anywhere> = True; | |
| my %out_files; | |
| sub MAIN( @in-files where { .IO.f // die "Input file $_ not found" }, | |
| Int :$f(:$field) = 0, | |
| Str :$d(:$delimiter) = ',', | |
| Str :$t(:$template) = '%') { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sub primes-any (Int $max) { | |
| my Int @primes; | |
| @primes.push($_) unless $_ %% any(@primes) for 2 .. $max; | |
| return @primes; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git log --since 2016-12-25 --oneline | perl6 -e 'say lines().grep(/(\d+\.?\d*?)\%(" "|$)/).map({/(\d+\.?\d*?)\%(" "|$)/; ~$/[0]}).sort.join("\n")' > %_increase.txt | |
| git log --since 2016-12-25 --oneline | perl6 -e 'say lines().grep(/(\d+\.?\d*?)x(" "|$)/).map({/(\d+\.?\d*?)x(" "|$)/; ~$/[0]}).sort.join("\n")' > x_increase.txt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl6 | |
| use v6; | |
| # Test files produced with mkfile -n 10m 10m for each file size | |
| my @file_sizes = <1m 10m 100m 1g 10g>; | |
| my @read_sizes = <1024 65536>; | |
| my %langs = ( ruby => {cmd => "\{time -p ruby -e 'while buf = STDIN.read(%d) do end' < %s\} 2>&1"}, | |
| perl5 => {cmd => "\{time -p perl -e 'while(read(STDIN,\$buf,%d)) {}' < %s\} 2>&1"}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use strict; | |
| use warnings; | |
| use English; | |
| use v5.10; | |
| my %pins; | |
| #Read lines from files given as cli arguments | |
| while (my $line = <<>>) { | |
| #Trim the newline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| normalised_name = 'joe bloggs' | |
| team_uuid = UUID('B54D2B9B-AEB3-4782-B452-CCB6D8F2850F') | |
| db.session.query(User.user_id).filter(User.user_id == UserTeam.user_id) \ | |
| .filter(UserTeam.team_uuid == team_uuid) \ | |
| .filter(func.levenshtein( | |
| func.unaccent( | |
| func.replace( | |
| func.lower( | |
| func.concat( | |
| User.first_name, ' ', User.last_name |