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
# Trying for a simpler version of https://gist.github.com/gfldex/e28992d7d85451ed669e7942f0b27e30 , | |
# because it gets down to the Iterator level, and also evaluates its condition twice for every value. | |
# All of these versions use the L1 record-matching logic I learned way back in | |
# the RPG language (where it was built into the language itself as L1,L2...L9 and MR indicators). | |
# Evaluates its condition N+1 times | |
sub batch2 (@list, &cluster) { | |
return lazy gather { |
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
=begin pod :kind("Language") :subkind("Language") :category("tutorial") | |
=TITLE Sorting | |
=SUBTITLE Guide to sorting in Raku | |
=head1 Quick solutions to common tasks | |
Simple sorts of list of values: | |
=begin code |
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
#!env perl6 | |
use v6; | |
$*ERR.print("Benchmark ", 'Miltiplier', ": "); | |
my $stime = now; | |
my $max_l = 20_000; | |
say :$max_l.perl; | |
my @l = 1..$max_l; # Hmmm. 2x here increases runtime by 4x | |
my $n; | |
for (^100) { # OK 10x here increases runtime by 10x |
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 v6; | |
# 2016-02-09 <[email protected]> | |
my $length = @*ARGS.shift; | |
say "Length = $length"; | |
my @x = 1..$length; | |
my @y = @x.reverse; |
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
# I think that this algorithm for handling the gzip'ed output files | |
# will be more efficient in speed, and vastly better in memory. | |
use Modern::Perl; | |
my $divider = 65000; | |
my ( $fileDate, $fileMinute ) = unpack 'x6 a8 x1 a4', $ARGV[0]; | |
sub format_a_records_file_counter { return sprintf '%02d', $_[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
# Just to show off the clarity of Perl 6. | |
# Code is untested! (Ran out of time.) | |
my @keys = < | |
callingNumber calledNumber numberBeforeTranslations dialedNumber | |
genericAddressParam ingressProtocol egressProtocol callDirection | |
ingressTgidName egressTgidName | |
>; | |
my @tnFields = @keys[0..4]; |
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
# This is what I did to get it Rosella working: | |
mkdir ~/new_rosella_dir | |
cd ~/new_rosella_dir | |
git clone https://github.com/Whiteknight/Rosella.git | |
cd Rosella/ | |
# Correct this for your Parrot path | |
PATH=$PATH:~/Perl/Parrot/Git/Parrot/parrot | |
# Only needed on Mac OS X | |
export DYLD_LIBRARY_PATH=~/Perl/Parrot/Git/Parrot/parrot/blib/lib | |
make |
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. Spelling corrected: Schwartzian transform | |
2. No need to use parens around \d{8}. | |
3. I like ST better, but GRT is faster for large lists: | |
http://www.perlmonks.org/?node_id=145659 | |
4. Need to warn or die to show bad data when regex fails. | |
5. Perl 6 automatically does ST for you: | |
my @sorted = @files.sort({ / SWITCH _ \d**8 _ (\d**6) / or die; $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
# Yes, you can put Moose classes in the same source file as your mainline code, rather than doing the CPAN-standard of one class per module. | |
# However, you must place the class definitions above the uses of the classes. | |
package Point; | |
use Moose; | |
has 'x' => ( isa => 'Int', is => 'rw' ); | |
has 'y' => ( isa => 'Int', is => 'rw' ); | |
__PACKAGE__->meta->make_immutable; |
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
#!perl | |
use strict; | |
use warnings; | |
# This code duplicates "Appendix B The Standard Normal Table" | |
# from a book used by Alexis in 2012 statistics class. | |
# 2012-03-09 <[email protected]> | |
# Wrote program in Perl 6, then converted to Perl 5. | |
use constant SQRT_2PI => sqrt( 8 * atan2(1,1) ); |
NewerOlder